Quantcast
Channel: Visual Studio General Questions forum
Viewing all articles
Browse latest Browse all 21115

When dll loaded as a resource a cast in the dll code throws an exception

$
0
0

I have an application that references about 12 dlls that are not part of the .net framework.  I would llike to include one or more of these dlls in the exe.  So, I am following the advice provided by Jeffrey Richter here http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx

 I added a debug version one of these dlls to the project and set it's build option and added the AssemblyResolve event handler according to Jeffrey's blog.  The dll seemed to load and run OK, except it threw a InvalidCastException where it does not occur when the dll is loaded normally as a file.  The dll defines an interface and a class that implements the interface.  The exception occurs where an instance of the class is created and cast as the interface, such as,

Type type = Type.GetType(aIDictionary["type"]);

ISomeInterface interface = (ISomeInterface) Activator.CreateInstance(type);


Viewing all articles
Browse latest Browse all 21115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>