调用 Assembly.GetExportedTypes() 时抛出 FileNotFoundException

发布于 2024-09-26 19:27:05 字数 1176 浏览 4 评论 0原文

在精简的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如何视而不见 2024-10-03 19:27:05

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文