Search code examples
c#clr

How to debug System.TypeLoadException errors in .NET?


I'm getting the following error on one of my referenced assemblies:

Could not load type 'System.Func`2' from assembly 'MyAssembly, ...

My first instinct was to see what MSDN had to say about it:

TypeLoadException is thrown when the common language runtime cannot find the assembly, the type within the assembly, or cannot load the type.

It appears to be is saying that the CLR simply can't find the type? That might make more sense if this wasn't something that was in mscorlib. This was all built on top of .NET4 with VS2010, so there's no mono or other weird library issues. What's going on?


Solution

  • The problem is that you have a mismatch in your versions. Make sure all your assemblies are compiled for .NET 4.