I am getting an error when using Reflection on PDFNet

Q: I am using Reflection to load assemblies in a folder, and with PDFNet I get the following error.

InnerException: .

ModuleLoadException

HResult=-2146233088

Message=The C++ module failed to load while attempting to initialize the default appdomain.

Any ideas what is happening?

A:

Because PDFNet for .Net contains unmanaged code, it has additional requirements when crossing appdomains (since managed and unmanaged are in different memory regions).

If you are using a security package with a class implementing IPrincipal, then you must inherit from the MarshalByRefObject class.

For more information see the following.

http://world.episerver.com/blogs/Svante-Seleborg/Dates/2011/10/The-type-initializer-for-Module-threw-an-exception/
https://groups.google.com/forum/#!topic/ausdotnetlist/9tGDLXklfZw
http://forums.lhotka.net/forums/p/4366/22838.aspx
http://stackoverflow.com/questions/1884030/implementing-a-custom-identity-and-iprincipal-in-mvc