以前工作的asp.net webforms应用程序现在抛出这个错误:

系统。MissingMethodException:方法未找到

DoThis方法在同一个类上,它应该可以工作。

我有一个通用的处理程序,这样:

public class MyHandler: IHttpHandler
{
    public void Processrequest(HttpContext context)
    {
      // throws error now System.MissingMethodException: 
      // Method not found.
      this.DoThis(); 
    }

    public void DoThis(){ ... }
}

当前回答

只是为了帮助任何人,虽然这是一个老问题,我的问题有点奇怪。

我在使用Jenkins时遇到了这个错误。

最终发现系统日期被手动设置为未来日期,这导致dll使用该未来日期编译。当日期被设置回正常时,MSBuild解释为文件更新,不需要重新编译项目。

其他回答

当DLL的旧版本仍然在某个地方徘徊时,就会出现这个问题。确保部署了最新的程序集,并且某些文件夹中没有隐藏重复的旧程序集。最好的办法是删除所有构建的项目,然后重新构建/重新部署整个解决方案。

I had a similar scenario where I was getting this same exception being thrown. I had two projects in my web application solution, named, for sake of example, DAL and DAL.CustSpec. The DAL project had a method named Method1, but DAL.CustSpec did not. My main project had a reference to the DAL project and also a reference to another project named AnotherProj. My main project made a call to Method1. The AnotherProj project had a reference to the DAL.CustSpec project, and not the DAL project. The Build configuration had both the DAL and DAL.CustSpec projects configured to be built. After everything was built, my web application project had the AnotherProj and DAL assemblies in its Bin folder. However, when I ran the website, the Temporary ASP.NET folder for the website had the DAL.CustSpec assembly in its files and not the DAL assembly, for some reason. Of course, when I ran the part that called Method1, I received a "Method not found" error.

为了修复这个错误,我必须从DAL更改AnotherProj项目中的引用。CustSpec到只是DAL,删除了临时ASP中的所有文件。NET Files文件夹,然后重新运行网站。从那以后,一切都开始运转了。我还确保了DAL。在“生成配置”中取消选中CustSpec项目后,没有生成该项目。

我想我要分享这个,也许它能在未来帮助到其他人。

这可能已经被提到了,但对我来说,问题是这个项目引用了2个nuget包,每个nuget包引用了另一个nuget包的不同版本。

So:

项目-> Nuget A -> Nuget X 1.1

项目-> Nuget B -> Nuget X 1.2

两个版本的Nuget X都有从Project中调用的相同扩展方法。

当我将Nuget A和B更新到引用相同版本的Nuget X时,错误就消失了。

我有一个测试项目,它引用了另外两个项目,每个项目引用了同一个dll的不同版本(在不同的位置)。这使编译器感到困惑。

我也有同样的事情发生,当我有许多MSBuild进程在后台运行时,它们实际上已经崩溃了(它们引用了旧版本的代码)。我关闭VS并在进程资源管理器中杀死所有MSBuild进程,然后重新编译。