我發現我的應用程序生成Telerik的報告一個類實例化在Assembly.GetTypes()
var result = new ReportProcessor().RenderReport("PDF", new InstanceReportSource { ReportDocument = new MyTelerikReport(data) }, null);
var stream = new MemoryStream(result.DocumentBytes);
return CreateHttpFileResponse("MyReport.pdf", stream, "application/pdf");
後我不能夠得到內CurrentDomain
var typesWithAttribute = (from a in AppDomain.CurrentDomain.GetAssemblies()
from t in a.GetTypes() //error appears here
//some filtering logic
select t).ToList();
我收到各類生產ReflectionTypeLoadException錯誤
System.Reflection.ReflectionTypeLoadException:無法加載一個或 更多請求的類型。檢索LoaderExceptions屬性 以獲取更多信息。
LoaderExceptions:
System.IO.FileNotFoundException:未能加載文件或組件 'DocumentFormat.OpenXml,版本= 2.0.5022.0文化=中性, 公鑰= 31bf3856ad364e35' 或之一它的依賴關係。 系統找不到指定的文件。文件名: 「DocumentFormat.OpenXml,版本= 2.0.5022.0,區域性=中性, 公鑰= 31bf3856ad364e35」
經過一番調查,我發現組件加載失敗:Telerik.Reporting.OpenXmlRendering, Version=8.0.14.311, Culture=neutral, PublicKeyToken=a9d7983dfcc261be
和組件不存在在AppDomain.CurrentDomain.GetAssemblies()
之前我生成報告(我假設程序集動態地由Telerik.Reporting, Version=8.0.14.311, Culture=neutral, PublicKeyToken=a9d7983dfcc261be
加載)。
我可以過濾掉那個程序集,因爲我不需要任何類型的程序,但是我有點擔心程序集在域中無法加載的事實 - 對我來說似乎有點不對勁。
有人可以解釋發生了什麼?是我的問題還是第三方庫的錯誤,不加載所有必需的程序集?