Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.MissingMethodException: Method not found?

People also ask

How do I fix MissingMethodException Method not found?

If you're encountering this error when running locally on your machine, try recompiling with the optimizeCompilations key set to false in your web.

What is System MissingMethodException?

MissingMethodException is designed to handle cases where an attempt is made to dynamically access a renamed or deleted method of an assembly that is not referenced by its strong name. MissingMethodException is thrown when code in a dependent assembly attempts to access a missing method in an assembly that was modified.


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.


⚠️ Wrong Nuget Package Version ⚠️

I had a unit test project which was pulling in our companies internal EF Nuget data access package and that code pulled in an external package whose version was way behind the current version.

The issue was that the Nuget settings for the top level package was set to the least version; and the lower level/older version won, and that was used during the operations....

Hence it silently got the wrong version for a common assembly used by both the package and the app.


💡 Solution 💡

By Setting/updating the package in Nuget to use and [get] the latest, fixed the issue.


I resolved this issue by installing the correct .NET Framework version on the server. The website was running under version 4.0 and the assembly it was calling to was compiled for 4.5. After installation of .NET Framework 4.5 and upgrading the website to 4.5, all works fine.


Restarting Visual Studio actually fixed it for me. I'm thinking it was caused by old assembly files still in use, and performing a "Clean Build" or restarting VS should fix it.


Check your References!

Be sure that you are consistently pointing to the same 3rd party libraries (don't just trust versions, look at the path) across your solutions projects.

For example, If you use iTextSharp v.1.00.101 in one project and you NuGet or reference iTextSharp v1.00.102 somewhere else you will get these types of runtime errors that somehow trickle up into your code.

I changed my reference to iTextSharp in all 3 projects to point to the same DLL and everything worked.


I had this happen to me with a file referenced in the same assembly, not a separate dll. Once I excluded the file from the project and then included it again, everything worked fine.