How can I troubleshoot : System.TypeLoadException?

佐手、 提交于 2019-12-01 15:22:18

In the exception message, or maybe in an InnerException property, you might find what was the requested type, with the fully qualified name, version, assembly. Check if the given assembly is reachable from the application directory. Reachable meaning in the application directory or in the private probing path of the application.

EDIT : also check that satellite assemblies (referenced by the assembly that the type loader fails loading) are reachable.

One situation where this exception is thrown is if the executing assembly has the same name as the assembly with the given type. For example, if you are running MyApp.exe and the type is in MyApp.dll, the CLR will assume that the type should be in MyApp.exe. A solution would be to rename one of those assemblies.

You could try switching on the 'Break when an exception is thrown' from Debug -> Tools -> Exceptions and click all the check boxes in the Thrown column. When you re-run your test you should be able to see exactly where this exception is being thrown.

pencilCake

Well... It was totally my bad.

I gave a wrong assembly name which was resulting a missing DLL in the bin folder.

Thanks to my mate, he pointed me to check the bin folder. And after checking the added reference's "path" I have noticed that it is looking to a completely different place.

Take a look into inner exception. This often happens when static constructor threw exception.

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