View Single Post
 
Old October 31st, 2008, 01:26 PM
stefsch stefsch is offline
Wrox Author
 
Join Date: Feb 2006
Location: Redmond, Washington, USA.
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Managed code calling into a native DLL requires unmanaged code permission. When an ASP.NET application runs in partial trust, all code in the /bin directory runs in a more restricted trust level which does not include unmanaged code permission. As a result when the managed code attempts to load the Win32 .dll, the load fails because the managed code doesn't have rights to interact with native code.

To fix this the managed code would need to be installed in the GAC, since all assemblies in the GAC are trusted, and hence are allowed to call native code even in partial trust environments. However installing the managed code in the GAC will also require that the managed assembly be APTCA attributed so that partial-trust user code in the ASP.NET application can call into the managed library.

-Stefan