“Unverifiable code failed policy check” for a clos

2019-02-27 19:00发布

I'm attempting to dynamically load some (purchased) assemblies from resource streams in a C# program during an MSI installation routine, but I'm getting "Unverifiable code failed policy check".

I read some tips online about compiling the embedded assembly with /clr:safe, but I don't have that option. Is there a way to work around this policy check?

Thanks.

3条回答
一纸荒年 Trace。
2楼-- · 2019-02-27 19:40

This may not be relevant any longer, but I encountered the same issue recently. If you take the stream and stick it in a temp file, you can then use Assembly.LoadFrom to load the assembly.

查看更多
Emotional °昔
3楼-- · 2019-02-27 19:45

Its already too late, but it may help someone.

I've used Sqlite DLL in my project and when I deployed the code on sandbox environment, I was getting exception (see below)

[FileLoadException: Unverifiable code failed policy check. (Exception from HRESULT: 0x80131402)]

[FileLoadException: Could not load file or assembly 'System.Data.SQLite, Version=1.0.79.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. Unverifiable code failed policy check. (Exception from HRESULT: 0x80131402)]

I added trust level within system.web in the web.config file and its working fine.

<trust level="Full|High|Medium|Low|Minimal" originUrl="url"/> 
查看更多
家丑人穷心不美
4楼-- · 2019-02-27 19:57

The only way to load unverifiable code is from a full trust process (or maybe app domain) with verification disabled.

EDIT: I'm not making this up, one of the C# language designers said "Unverifiable code requires full trust and is generally to be avoided"

查看更多
登录 后发表回答