Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

c# - Common Language Runtime detected an invalid program?

I have this error repeating continuously in my program.

I have tried the following:

  1. Restart Visual Studio
  2. Clean and Rebuild Solution

When I step through the code line by line, it stops leaving me totally confused at a method call:

GenerateWorksheetPart1Content(WorksheetPart worksheetPart1)

I don't understand why it stops there. The parameter is not null at the point. What could be causing the error?

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

MSDN - InvalidProgramException

Excerpt:

The exception that is thrown when a program contains invalid Microsoft intermediate language (MSIL) or metadata. Generally this indicates a bug in the compiler that generated the program.

This is happening as you step through the code because as your method is called it is being JIT compiled. If the compilation by the JITer is invalid, this exception will be thrown at this point.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...