Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solution to TypeLoadException

I just wanted to share something I learned. There are many posts about TypeLoadExceptions here, but none of them seemed to have the answer I needed.

This page has some particularly good information, but didn't seem to specifically address what I was seeing and how I resolved it (could be wrong):

TypeLoadException says 'no implementation', but it is implemented

The SOLUTION for me was simple: Delete any files Visual Studio 2010 caches and uses to generate assembly files.


Background of the Problem:

Here are some more details. I was seeing a TypeLoadException like:

Unhandled Exception: System.TypeLoadException: Method [method name] in type [type name] from assembly [assembly name], Version=x.x.x.x, Culture=neutral, PublicKeyToken=null does not have an implementation.

I did have an implementation...I thought, until I looked at the assembly with ILDASM. I discovered I was getting old versions of DLLs written to my ouput folder that had outdated interfaces. My output folder was not the default setting, but a relative path outside of the project folder (maybe VS can't handle this completely??). After doing clean/rebuild on the project, the project's "obj" folder was the only folder in all child folders of my project folder that had the correct datestamp on the DLL. The "bin" folder for some reason still had an old version. And I suppose that was what was getting copied to the output folder.

Before this I had tried:

  • clean/rebuild
  • restarting Visual Studio (2010)
  • rebooting
  • deleting my assembly DLLs in the output folder (bin\x86\debug)

...with no success.

I'm not sure why VS wasn't copying the correct assembly in "obj" to the output folder... The project that referenced the outdated assembly was correct.

like image 462
jbobbins Avatar asked Dec 15 '11 23:12

jbobbins


1 Answers

Are you using some kind of source control and doing check in and check out stuff? If yes, make sure that the obj and bin folders are not checked in to the source control. If they are then delete them from the source control, check everything in, and then re-build your solution.

like image 161
Azhar Khorasany Avatar answered Oct 09 '22 01:10

Azhar Khorasany