Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

winforms - How to diagnose "System.TypeLoadException" error

When I attempt to open my Windows Forms application (I'll call it MyApplication.exe) on a machine other than my dev machine, a dialog window pops up saying:


MyApplication has stopped working

Windows can check online for a solution to the problem

  • Check online for a solution and close the program
  • Close the program

Details

Problem signature:

  Problem Event Name:   CLR20r3
  Problem Signature 01: myapplication
  Problem Signature 02: 1.2.0.0
  Problem Signature 03: 51c34395
  Problem Signature 04: mscorlib
  Problem Signature 05: 4.0.0.0
  Problem Signature 06: 50484bd7
  Problem Signature 07: 1204
  Problem Signature 08: 89
  Problem Signature 09: System.TypeLoadException
  OS Version:   6.1.7600.2.0.0.256.48
  Locale ID:    1033
  Additional Information 1: 0a9e
  Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
  Additional Information 3: 0a9e
  Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

It's important to note that I use ILMerge to merge the MyApplication.exe and a referenced MyLibrary.dll assemblies together into one assembly (the name of the output is MyApplication.exe).

Also, it's important to note that the testing machines were able to run the .exe with no problems until I released an update that added an extension method to the MyApplication project.

In other words, after I added the extension method to MyApplication, then used ILMerge to combine the .exe and .dll, the testing machines would receive the above error (Interestingly, my dev machine could run the merged .exe with no problems).

Is there a known issue w/ ILMerge and Extension Methods? That sounds odd, but that's the only thing that has changed in my code.

Since I cannot reproduce the problem on my dev machine, do you have any advice on how I can go about troubleshooting the System.TypeLoadException error that occurs on the test machines?

System Info

  • Targeting .NET Framework 4.0 (all my test machines have this installed)
  • ILMerge Version 2.12.803
  • Dev Machine: Windows 2008 Server R2; Visual Studio 2010 Pro
  • Client Machines: XP, Win7, and Win8 (all of them get the error)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you have .net 4.5 installed on your build machine, it would break if your not careful.

Basically Microsoft changed where 1 attribute was located (from System.Core to mscorlib).

Matt Wrock in his post explains how to workaround it with ILMerge. Although this is for the beta, it should work with the release.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...