以前工作的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(){ ... }
}

当前回答

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项目后,没有生成该项目。

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

其他回答

在我的案例中,spotify.exe使用的端口与我的web api项目想要在开发机器上使用的端口相同。端口号为4381。

我退出了Spotify,一切又恢复正常了:)

如果使用自己的NuGet服务器开发,请确保程序集版本都相同:

[assembly: AssemblyVersion("0.2.6")]
[assembly: AssemblyFileVersion("0.2.6")]
[assembly: AssemblyInformationalVersion("0.2.6")]

当方法需要一个我没有指定的参数时,我就遇到了这个问题

也. .尝试“清理”您的项目或解决方案并重新构建!

在更新各种Nuget包后遇到这个错误。检查Visual Studio错误列表(或构建输出),查看类似以下的警告:

发现同一依赖项的不同版本之间存在冲突 组装。在Visual Studio中,双击此警告(或选择它) 并按Enter)来修复冲突;否则,添加如下内容 绑定重定向到应用程序中的“运行时”节点 配置文件: ...

在Visual Studio中双击此警告会自动调整我的web中的各种bindingRedirect包版本。配置并解决了错误。