How do I dinamically load raw assemblies that contains unmanaged code?(bypassing 'Unverifiable code

Posted by Thiado de Arruda on Stack Overflow See other posts from Stack Overflow or by Thiado de Arruda
Published on 2010-05-31T17:31:42Z Indexed on 2010/05/31 17:33 UTC
Read the original article Hit count: 535

I'm going to give an example of using System.Data.SQLite.DLL which is a mixed assembly with unmanaged code: If I execute this :

  var assembly= Assembly.LoadFrom("System.Data.SQLite.DLL")

No exceptions are thrown, but if I do this :

  var rawAssembly = File.ReadAllBytes("System.Data.SQLite.DLL");
  var assembly = Assembly.Load(rawAssembly);

The CLR throws a FileLoadException with "Unverifiable code failed policy check. (Exception from HRESULT: 0x80131402)". Let's say I'm trying to load this assembly on a child AppDomain, how can I customize the AppDomain's security to allow me pass the policy check?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET