【发布时间】:2012-02-23 23:33:46
【问题描述】:
我正在尝试在运行时在服务器端 DLL 上加载嵌入式程序集。我嵌入的程序集是我自己的代码。
我在尝试加载程序集时收到 Unverifiable code failed policy check 错误。
有没有办法解决这个问题?
代码如下:
byte[] resource = null;
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name))
{
if (stream != null)
{
resource = new byte[stream.Length];
stream.Read(resource, 0, (int)stream.Length);
}
}
AppDomain.CurrentDomain.Load(resource);
编辑:
有点摸不着头脑,但我尝试先将 DLL 保存到磁盘,然后以这种方式加载。这是我现在得到的:无法加载文件或程序集或其依赖项之一。给定的程序集或代码库无效。
【问题讨论】:
-
发现了这个老问题。也许是你的情况:(stackoverflow.com/questions/2612128/…)
-
您是否尝试过检查项目配置中的“允许不安全代码”?
标签: c# embedded-resource