调用 Assembly.GetExportedTypes() 时抛出 FileNotFoundException
在精简的 XP SP3 x86 虚拟机上运行 .net 2.0 应用程序时,即使在安装应用程序之前已经安装了 .net 2.0 框架运行时,我也会收到此错误。
Exception Source: mscorlib Exception Type: System.IO.FileNotFoundException Exception Message: Could not load file or assembly 'WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. Exception Target Site: GetExportedTypes ---- Stack Trace ---- System.Reflection.Assembly.GetExportedTypes() XSplit.Core.exe: N 00000 XSplit.Core.Capture.ChannelAddinManager.#Dm( As String) XSplit.Core.exe: N 00105 XSplit.Core.Capture.ChannelAddinManager.#Cm() XSplit.Core.exe: N 00265 XSplit.Core.Capture.ChannelAddinManager.Init(path As String, host As IAddinHost) XSplit.Core.exe: N 00104 XSplit.Core.frmLogin.InitializeAddinComponent() XSplit.Core.exe: N 00534 XSplit.Core.frmLogin..ctor(args As String[]) XSplit.Core.exe: N 01263
产生此错误的相关代码是这样
var assembly = Assembly.LoadFrom(dllFile); var assemblyTypes = assembly.GetExportedTypes();
即使安装framework 2.0 sp2后,仍然会抛出此错误。
你们知道这是为什么吗?
I'm getting this error when running a .net 2.0 app on a stripped-down XP SP3 x86 virtual machine, even if .net 2.0 framework runtime has already been installed prior to installing the app.
Exception Source: mscorlib Exception Type: System.IO.FileNotFoundException Exception Message: Could not load file or assembly 'WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. Exception Target Site: GetExportedTypes ---- Stack Trace ---- System.Reflection.Assembly.GetExportedTypes() XSplit.Core.exe: N 00000 XSplit.Core.Capture.ChannelAddinManager.#Dm( As String) XSplit.Core.exe: N 00105 XSplit.Core.Capture.ChannelAddinManager.#Cm() XSplit.Core.exe: N 00265 XSplit.Core.Capture.ChannelAddinManager.Init(path As String, host As IAddinHost) XSplit.Core.exe: N 00104 XSplit.Core.frmLogin.InitializeAddinComponent() XSplit.Core.exe: N 00534 XSplit.Core.frmLogin..ctor(args As String[]) XSplit.Core.exe: N 01263
The related code that spawns this error is this
var assembly = Assembly.LoadFrom(dllFile); var assemblyTypes = assembly.GetExportedTypes();
Even after installing framework 2.0 sp2, this error is still thrown.
You guys got any clue on why this is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WindowsBase 程序集直到 .NET 3.0 才可用。如果你想运行这段代码而不出现异常,那么你需要在机器上安装 3.0,2.0 还不够好。检查外接程序项目的生成设置并确保它不引用任何 WPF 程序集。
The WindowsBase assembly didn't become available until .NET 3.0. If you want to run this code without an exception then you'll need to install 3.0 on the machine, 2.0 isn't good enough. Check the build settings for the add-in project and make sure that it doesn't reference any WPF assemblies.