简体   繁体   中英

What does “Illegal use of type 'void' in signature” mean?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM