3
我想在運行時加載一個嵌入式程序集的服務器端DLL。我嵌入的程序集是我自己的代碼。加載嵌入式彙編
我正在試圖加載程序集時無法驗證的代碼失敗的政策檢查錯誤。
有沒有辦法解決這個問題?
下面是代碼:
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到磁盤,並加載它的方式。以下是我現在得到的內容:無法加載文件或程序集或其中一個依賴項。給定的程序集或代碼庫是無效的。
發現這個老問題。也許這是你的情況: (http://stackoverflow.com/questions/2612128/unverifiable-code-failed-policy-check-for-a-closed-source-assembly) – Steve 2012-02-22 22:48:19
你嘗試檢查「允許不安全代碼'在項目配置? – Steve 2012-02-22 23:44:11