By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,865 Members | 1,717 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,865 IT Pros & Developers. It's quick & easy.

Plugin Interface and Invalid Cast Exceptions

P: 1
I develop an application that uses a plugin interface, that the hosting application as well as the plugins implement. Each plugin is loaded via:

newPlugin.Instance = (IPlugin)Activator.CreateInstance(pluginAssembly.G etType(pluginType.ToString()));

All Plugins are inside a sub directory called "plugins" of the main application.

Now I developed one plugin that should implement a network interface, using external dll's from a framework i wrote some time ago. This framework binary serializes objects, compresses them and sends them over the net.

When I receive such an Object in the Plugin, i can deserialize it without any problem and it is showed correctly while debugging as "object" type (resulting from the deserialization). Now, when I try to cast this object to a structure (that is described in an external dll - an object library - which is the same at the sending an receiving side) i get a "Cast Exception" in the plugin.

By the way, the object and it's type look correctly while debugging and, i can send such objects from this application to the remote one, that also can cast them, using exact the same dll (the object library).

I searched around a lot, but found no real answer...
Maybe the problem is that "Activator.CreateInstance" loads the plugin assembly into a wrong appDomain, because the remote application does not use plugins and refers to the object library - dll directly.

The source code is a bit complex, so i hope that someone might be able to help me just with this description of the problem.

Thx in advance,

Sep 4 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.