After trying all of the answers listed here, I have a new one:
The type initializer for 'MyLibrary' threw an exception.
If you see something like the below in the InnerException(s)..........
"Could not load file or assembly 'log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The system cannot find the file specified.":"log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a"
In my case, my directory had the correct version dll. (log4net.dll in this case).
And then ... the issue was found. Assembly redirects in the app.config.
:(
Since I had the correct version, I removed all my redirects. Your situation may be different.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="b32731d11ce58905" />
<codeBase version="1.2.9.0" href="log4netv1.2.9.0\log4net.dll" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" />
<codeBase version="1.2.10.0" href="log4netv1.2.10.0\log4net.dll" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" />
<codeBase version="1.2.13.0" href="log4netv1.2.13.0\log4net.dll" />
</dependentAssembly>
</assemblyBinding>
</runtime>
TypeInitializationException
you need to check the InnerException property for more details – Sriram SakthivelProgram.Main()
So I am not able to debug my code. I hit F5 and get this exception. And unfortunately this exception dialog does not have View Details link. So I think down vote on this question will be removed. – Mahesha999static Program()
constructor as well recognized by @Marc Gravell below, wish the exception description could have told me that. – Mahesha999