调用Assembly.GetExportedTypes()时抛出FileNotFoundException

时间:2010-10-08 10:35:12

标签: c# .net-2.0 x86 vmware-workstation windows-xp-sp2

我在精简的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之后,仍会抛出此错误。

你们对这是为什么有任何线索?

1 个答案:

答案 0 :(得分:2)

在.NET 3.0之前,WindowsBase程序集才可用。如果你想毫无例外地运行这个代码,那么你需要在机器上安装3.0,2.0还不够好。检查加载项项目的构建设置,并确保它不引用任何WPF程序集。