2

I have a compiler that's producing an assembly. When I load the assembly and try to run a method on an object whose class is in that assembly, it throws an exception:

System.InvalidProgramException: Common Language Runtime detected an invalid program.

As error messages go, this is only exactly as informative as UR COMPILER SUXX0RZ LOLOLOL!!! Looking it up on MSDN says the same thing: there's something wrong with the compiler.

So I tried running PEVerify on the generated assembly and got a slightly more useful message:

[MD]: Error: Illegal use of type 'void' in signature. [token:0x11000002]

Unfortunately, it doesn't say anything beyond that, such as what signature has an illegal void. You know, the kind of stuff that's useful for tracking down reported errors...

Opening it up in ILDASM, I don't see any obviously wrong void-ness hanging around, so what's the next step? Where do I go from here to figure out what my compiler is doing wrong?

Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477
  • Publish invalid dll somewhere for us to see? Until that my wild guess would be that you use void as function input parameter type somewhere. – Evk Sep 20 '15 at 20:33
  • @PetSerAl: That worked, and I was able to locate the problem. Post that an an answer and I'll accept it. – Mason Wheeler Sep 20 '15 at 20:44

1 Answers1

4

You can use /TOKENS parameter to IL DASM. That make IL DASM to show token's values as comments. Given token's value from PEVerify error message, you can easily locate problem element of assembly.

user4003407
  • 21,204
  • 4
  • 50
  • 60