Solution to TypeLoadException

ⅰ亾dé卋堺 提交于 2019-12-10 12:55:30

问题


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.


回答1:


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.




回答2:


I had this kind of problem in Visual Studio 2015, and solved it by using the NuGet package manager for the solution, to reinstall a package that had somehow been installed in different versions.



来源:https://stackoverflow.com/questions/8527966/solution-to-typeloadexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!