TypeLoadException表示“没有实现”,但它已实现

TypeLoadException表示“没有实现”,但它已实现

我的测试机器上有一个非常奇怪的错误。错误是:

System.TypeLoadException: Method 'SetShort' in type 'DummyItem' from assembly 'ActiveViewers (...)' does not have an implementation.

我只是无法理解为什么。SetShortDummyItem课堂上有,我甚至重新编译了一个带有写入事件日志的版本,只是为了确保它不是部署/版本问题。奇怪的是调用代码甚至不调用该SetShort方法。


芜湖不芜
浏览 924回答 3
3回答

侃侃无极

除了提问者自己的答案之外,还可能值得注意以下几点。发生这种情况的原因是因为类可以使用与接口方法具有相同签名的方法而不实现该方法。以下代码说明:public interface IFoo{    void DoFoo();}public class Foo : IFoo{    public void DoFoo() { Console.WriteLine("This is _not_ the interface method."); }    void IFoo.DoFoo() { Console.WriteLine("This _is_ the interface method."); }}Foo foo = new Foo();foo.DoFoo();               // This calls the non-interface methodIFoo foo2 = foo;foo2.DoFoo();              // This calls the interface method

慕婉清6462132

当我的应用程序没有引用定义错误消息中使用的方法的类的另一个程序集时,我得到了这个。运行PEVerify会产生更多有用的错误:“系统无法找到指定的文件。”
打开App,查看更多内容
随时随地看视频慕课网APP