What once was working in my asp.net webforms app now throws this error:
System.MissingMethodException: Method not found
The DoThis
method is on the same class and it should work.
I have a generic handler as such:
public class MyHandler: IHttpHandler
{
public void Processrequest(HttpContext context)
{
// throws error now System.MissingMethodException: Method not found?
this.DoThis();
}
public void DoThis()
{
//
}
}
I ran into this issue, and what it was for me was one project was using a List which was in Example.Sensors namespace and and another type implemented the ISensorInfo interface. Class Type1SensorInfo, but this class was one layer deeper in the namespace at Example.Sensors.Type1. When trying to deserialize Type1SensorInfo into the list, it threw the exception. When I added using Example.Sensors.Type1 into the ISensorInfo interface, no more exception!
I had a test project that references 2 other projects that each referenced different versions (in different locations) of the same dll. This confused the compiler.
This is a problem which can occur when there is an old version of a DLL still lingering somewhere around. Make sure that the latest assemblies are deployed and no duplicated older assemblies are hiding in certain folders. Your best bet would be to delete every built item and rebuild/redeploy the entire solution.
If developing with your own NuGet server, make sure the assembly versions are all the same:
I've had the same thing happen when I had a number of MSBuild processes running in the background which had effectively crashed (they had references to old versions of code). I closed VS and killed all the MSBuild processes in process explorer and then recompiled.
In my case it was a copy/paste problem. I somehow ended up with a PRIVATE constructor for my mapping profile:
(take note of the missing "public" in front of the ctor)
which compiled perfectly fine, but when AutoMapper tries to instantiate the profile it can't (of course!) find the constructor!