我们的测试机器上有个很奇怪的bug。错误是:
系统。来自程序集“activeviewer(…)”的类型“DummyItem”中的方法“SetShort”没有实现。
我就是不明白为什么。SetShort在DummyItem类中,我甚至重新编译了一个版本,写入事件日志,只是为了确保它不是部署/版本控制问题。奇怪的是,调用代码甚至不调用SetShort方法。
我们的测试机器上有个很奇怪的bug。错误是:
系统。来自程序集“activeviewer(…)”的类型“DummyItem”中的方法“SetShort”没有实现。
我就是不明白为什么。SetShort在DummyItem类中,我甚至重新编译了一个版本,写入事件日志,只是为了确保它不是部署/版本控制问题。奇怪的是,调用代码甚至不调用SetShort方法。
当前回答
I had the same problem. I figured out that my assembly, which is loaded by the main program, had some references with "Copy Local" set to true. These local copies of references were looking for other references in the same folder, which did not exist because the "Copy Local" of other references was set to false. After the deletion of the "accidentally" copied references the error was gone because the main program was set to look for correct locations of references. Apparently the local copies of the references screwed up the sequence of calling because these local copies were used instead of the original ones present in the main program.
重要的信息是,出现此错误是因为缺少加载所需程序集的链接。
其他回答
当我之前在一个程序集的单元测试期间启用了代码覆盖时,我也得到了这个错误。由于某种原因,Visual Studio“缓冲”了这个特定DLL的旧版本,即使我已经更新了它以实现新版本的接口。禁用代码覆盖消除了错误。
我也有这个错误,这是由任何CPU exe引用的任何CPU程序集,反过来引用x86程序集引起的。
异常抱怨MyApp中类的一个方法。实现(任何CPU),它派生了MyApp。接口(任何CPU),但在fuslogvw.exe中,我发现了一个隐藏的“试图从MyApp加载格式不正确的程序”异常。CommonTypes (x86),两者都使用它。
我在以下场景中收到此错误。
程序集A和程序集B都引用了System.Web.Mvc Version 3.0.0.0 程序集A引用程序集B,并拥有实现程序集B接口的类,这些类的方法返回来自System.Web.Mvc的类。 程序集A升级到System.Web.Mvc版本4.0.0.0 程序集C运行下面的代码(FertPin.Classes。Contact包含在Assembly A):
var target = Assembly.GetAssembly(typeof(FertPin.Classes.Contact));
对我来说,修复是将程序集B中的System.Web.Mvc引用升级到4.0.0.0。现在看来很明显了!
感谢原来的海报!
我在WCF服务中得到了这个,因为选择了x86构建类型,导致箱子在bin\x86下而不是bin下。选择Any CPU会导致重新编译的dll到达正确的位置(我不会详细说明这是如何发生的)。
这仅仅意味着实现项目在我的案例中已经过时了。重新构建了包含接口的DLL,但实现DLL陈旧。