1
System.MissingMethodException: Method not found: 
  'System.Collections.Generic.List`1<!!0> 
  BusinessEntities.Helper.Sort(System.Func`2<!!0,!!0>)'

I get this error on a page in the website.The website build is prepared using visual studio web deployment project. When I deploy the build in IIS and run the page, I get the above error. When the website is run in debug mode in visual studio, it executes fine.

Background : I have a asp.net 4.0 website which references the BusinessEntities project, which is a .NET 3.5 class library project. The project contains a public static Helper class which has the extension method Sort for sorting generic lists of objects. The Helper class is in the BusinessEntities namespace.

If I change the version of the BusinessEntites project to .Net 4.0 and then build the website, this error does not arise. The project cannot be upgraded to 4.0 due to some operational restrictions.

The strange thing in all this is that the generic extension method and the website and project structure has been in the solution since over a year without any issues. I am at a loss to understand why this error pops up all of a sudden.

Grant Winney
  • 65,241
  • 13
  • 115
  • 165
drj
  • 11
  • 1
  • 2

2 Answers2

3

A MissingMethodException means that you are loading a different version of the dll than the one you referenced during your build, and the actual dll you are loading (at run-time) doesn't have the method the compiler found (at compile-time).

Check that you haven't somehow got different versions of the same dll referenced in your project. It might be that when you run it in debug mode, some other code makes the correct dll load first, but when running in release a different dll gets loaded due to reference mismatch, or you might have multiple versions of it somewhere.

Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321
  • The website has a project reference to the BusinessEntities project. I checked the datetime stamp of the BusinessEntities.dll and it matches the current timestamp for the project. I even tried replacing the latest dll from the project build to the website build. still didnt work. there is no other dlls with thesame name in the build. If I comment out the sort method from the page, it works without issue. That means that other classes from the BusinessEntites project are accessible in the build. Also,i wonder why , when I change the project target framework to 4.0, this issue does not arise. – drj Apr 27 '14 at 16:03
  • Did you try deleting all references, dlls and recompiling? Might the DLL be in the GAC by any chance? – Yuval Itzchakov Apr 27 '14 at 16:06
  • Yes, have tried deleting, cleaning solution and rebuilding. I have not added the project dlls to GAC. But checked in the GAC just to be sure and its not there. Have even tried deleting the temporary asp.net files. – drj Apr 27 '14 at 16:17
  • 1
    I did a full rebuild on the solution and it error went away. – Gary Kindel Feb 03 '15 at 20:27
-1

I was facing same issue ,I have fixed using below steps... 1. Clean you solution 2. manually clean bin folder 3. delete temp folder 4. rebuild solution.

lazydeveloper
  • 891
  • 10
  • 20