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

当前回答

我遇到了这个问题,对我来说,它是一个项目,在例子中使用一个列表。传感器命名空间和另一种类型实现了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() 
    }
}

其他回答

在我的例子中,我的项目引用了Microsoft.Net.Compilers.2.10.0。当我把它切换到Microsoft.Net.Compilers.2.7.0时,错误消失了。有这么多原因的一个多么神秘的错误。

我通过在服务器上安装正确的. net Framework版本解决了这个问题。该网站在4.0版本下运行,它调用的程序集是针对4.5编译的。在安装。net Framework 4.5并将网站升级到4.5之后,一切工作正常。

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

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

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

我遇到了这个问题,对我来说,它是一个项目,在例子中使用一个列表。传感器命名空间和另一种类型实现了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() 
    }
}

在我的情况下,它是一个具有相同名称的旧dll的文件夹,这些dll在我的.csproj文件中被引用,尽管路径显式地给出了它们,但它们以某种方式被包括在内,因此相同dll的几个版本存在冲突。