Dynamic proxy class names

18 views
Skip to first unread message

Jeffrey Keyser

unread,
Sep 19, 2016, 9:43:39 AM9/19/16
to Castle Project Users
Hello, all.

I am working with the Dynamic Proxy feature, and am looking for a way to deal with a serialization problem that I expect to crop up.

First, a little background.  I am working on code that builds dynamic proxies using a single base concrete class and a list of interfaces, one of which changes based on the specific type of object I need to emulate.  New types are being created for each different interface exactly as expected, and their names are "Castle.Proxies.ConcreteClassProxy," "Castle.Proxies.ConcreteClassProxy_1," "Castle.Proxies.ConcreteClassProxy_2," etc.  These proxy objects also need to be serialized away and deserialized on postback.  I have all of this is working perfectly for me locally in IIS Express.

However, I am predicting that if I were to deploy this code into our 6-server web farm, there will be problems.  Since the class names are being generated with these sequential numbers based on the order in which they are needed, which ultimately depends on the order in which pages are requested by users, the dynamic type names for interfaces X and Y could be different between servers depending on which one was created first.  And I also assume that this will cause deserialization problems if a proxy object is created on one server and deserialized on another because of the type names being different.

I was trying to figure out if there were a way to name the dynamic classes after both the concrete class AND the implemented interfaces.  I found a Stack Overflow article where someone suggested a way to control the class names by injecting a custom INamingScope object, but this appears to be called too late in the process to do what I want to do.  And there also appears to be no good way to inject such behavior into the BaseProxyGenerator, which is where the dynamic type name is created.

So I my question for everyone is two-fold.  First, am I correct that this will be an issue that needs to be resolved?  Second, if so, does anyone have a suggestion for how to most correctly address this?

Thanks.

Jonathon Rossi

unread,
Sep 21, 2016, 4:42:28 AM9/21/16
to Castle Project Users
Hi Jeffrey,

Yes, this would be a problem even on the same machine if the process restarts (e.g. app pool recycle).

How are you serializing these objects, I don't think it would be a good idea for your web app to expose any details about its actual implementation like type names.

Jono

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castle-project-u...@googlegroups.com.
To post to this group, send email to castle-pro...@googlegroups.com.
Visit this group at https://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages