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

当前回答

我解决了这个问题,我做了一个搁置我的变化和运行TFS电动工具“烧焦”在我的工作空间(https://visualstudiogallery.msdn.microsoft.com/f017b10c-02b4-4d6d-9845-58a06545627f)。然后我取消了更改并重新编译项目。 这样你就可以清理你工作空间里的“挂着的聚会”,并重新开始一个新的聚会。 当然,这要求您使用TFS。

其他回答

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

我在测试同事编写的一些代码时遇到了这个异常。以下是异常信息的摘要:

方法未找到:“System.Threading.Tasks.Task1< microsoft . entityframeworkcore . changetrackingentityentry1 <System_Canon>> . System_Canon . changetrackingentityentry1” Microsoft.EntityFrameworkCore.DbSet“1. addasync…

这是在Visual Studio 2019中针对. net Core 3.1的类库中。修复方法是在DbSet上使用Add方法而不是AddAsync。

在我的情况下,根本没有代码更改,突然一个服务器开始得到这个,只有这个异常(所有服务器都有相同的代码,但只有一个开始有问题):

System.MissingMethodException: Method not found: '?'.

栈:

Server stack trace: 
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at myAccountSearch.AccountSearch.searchtPhone(searchtPhoneRequest request)
   at myAccountSearch.AccountSearchClient.myAccountSearch.AccountSearch.searchtPhone(searchtPhoneRequest request)
   at myAccountSearch.AccountSearchClient.searchtPhone(String ID, String HashID, searchtPhone Phone1)
   at WS.MyValidation(String AccountNumber, String PhoneNumber)

我认为这个问题是AppPool被破坏了——我们每天凌晨3点自动回收AppPool,这个问题从凌晨3点开始,然后在第二天凌晨3点自行结束。

我遇到了这个问题,对我来说,它是一个项目,在例子中使用一个列表。传感器命名空间和另一种类型实现了ISensorInfo接口。类Type1SensorInfo,但是这个类在Example.Sensors.Type1的命名空间中更深一层。当试图将Type1SensorInfo反序列化到列表中时,会抛出异常。当我使用Example.Sensors添加时。输入1到ISensorInfo接口,没有更多的异常!

namespace Example
{
    public class ConfigFile
    {
        public ConfigFile()
        {
            Sensors = new List<ISensorInfo<Int32>>();
        }
        public List<ISensorInfo<Int32>> Sensors { get; set; }
     }
   }
}

**using Example.Sensors.Type1; // Added this to not throw the exception**
using System;

namespace Example.Sensors
{
    public interface ISensorInfo<T>
    {
        String SensorName { get; }
    }
}

using Example.Sensors;

namespace Example.Sensors.Type1
{
    public class Type1SensorInfo<T> : ISensorInfo<T>
    {
        public Type1SensorInfo() 
    }
}

肯定是微软的参考bug。

我清理,重建了我所有的库,仍然有同样的问题,无法解决这个问题。

我所做的就是关闭Visual Studio应用程序,然后重新打开它。这招奏效了。

令人沮丧的是,这么简单的一个问题却要花这么长时间来解决,因为你不会想到它会是这样的。