我们的测试机器上有个很奇怪的bug。错误是:

系统。来自程序集“activeviewer(…)”的类型“DummyItem”中的方法“SetShort”没有实现。

我就是不明白为什么。SetShort在DummyItem类中,我甚至重新编译了一个版本,写入事件日志,只是为了确保它不是部署/版本控制问题。奇怪的是,调用代码甚至不调用SetShort方法。


当前回答

FWIW,当有一个配置文件重定向到引用程序集的不存在版本时,我得到了这个。融合日志为胜利而战!

其他回答

当我的应用程序没有对另一个程序集的引用时,我得到了这个,该程序集定义了错误消息中的方法使用的类。运行PEVerify会给出更有用的错误:“系统无法找到指定的文件。”

我刚刚将一个解决方案从MVC3升级到MVC5,并开始从我的单元测试项目中收到相同的异常。

检查所有的引用寻找旧文件,最终发现我需要做一些bindingRedirects Mvc,在我的单元测试项目。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

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.

重要的信息是,出现此错误是因为缺少加载所需程序集的链接。

Our problem solved with updating windows! Our web application is on .Net 4.7.1 and c# 7.0. As we tested in different windowses, we understood that the problem will be solved by updating windows. Indeed, the problem was seen in windows 10 (version 1703) and also in a windows server 2012(not updated in last year). After updating both of them, the problem was solved. In fact, the asp.net minor version(the third part of the clr.dll version in C:\Windows\Microsoft.NET\Framework64\v4.0.30319 ) was changed a bit after the update.

作为补充:如果更新用于生成假程序集的nuget包,也会发生这种情况。假设您安装了一个nuget包的V1.0版本,并创建了一个假程序集“fakeLibrary.1.0.0.0.Fakes”。接下来,更新到nuget包的最新版本,比如v1.1,它向接口添加了一个新方法。Fakes库仍在寻找该库的1.0版本。只需移除假组装和再生它。如果这是问题所在,这可能会解决它。