在我的 C# 类中运行良好,但从昨天开始,当我尝试运行该程序时突然出现以下错误。当我尝试构建解决方案时,它构建成功。
Could not load type 'FileNet.Api.Admin.IRepository' from
assembly 'FileNet.Api, Version=4.0.0.0, Culture=neutral, PublicKeyToken=63fc2fb3fdeef4f1'.
当我尝试调试解决方案时,我在 SetOSNames() 处收到上述错误;我无法进入 SetOSNames();方法。
请帮忙
private void IntializeVariables(IConnection connection)
{
domain = Factory.Domain.FetchInstance(connection, null, null);
domainName = domain.Name;
ost = domain.ObjectStores;
SetOSNames(); ///Error thrown here
}
//
// Intializes the ArrayList osNames with object store names.
//
public void SetOSNames()
{
IEnumerator ie = ost.GetEnumerator();
while (ie.MoveNext())
{
IObjectStore os = (IObjectStore)ie.Current;
osNames.Add(os.DisplayName);
}
}
最佳答案
编译器对您的代码感到满意,这表明引用程序集与运行时找到的程序集不匹配。使用 Fuslogvw.exe 工具找出正在加载的程序集。请务必记录所有绑定(bind),而不仅仅是失败的绑定(bind)。它找到错误版本的 FileNet.Api.dll 的可能性很大,可能是因为旧版本存储在 GAC 中。避免在您的开发机器上使用 GAC。
关于c# - 无法在 C# 中加载类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4699685/