次の方法で共有


PEVerify Tool (Peverify.exe)

The PEVerify tool helps developers who generate Microsoft intermediate language (MSIL) (such as compiler writers, script engine developers, and so on) to determine whether their MSIL code and associated metadata meet type safety requirements. Some compilers generate verifiably type-safe code only if you avoid using certain language constructs. If, as a developer, you are using such a compiler, you may want to verify that you have not compromised the type safety of your code. In this situation, you can run the PEVerify tool on your files to check the MSIL and metadata.

peverify filename [/md] [/il] [/break=maxErrorCount]
[/hresult] [/ignore= hex.code] [/ignore=@responseFile]
[/unique] [/quiet]
Argument Description
filename The portable executable (PE) file for which to check the MSIL and metadata.
Option Description
/break=maxErrorCount Aborts verification after maxErrorCount errors.
/clock Measures and reports the following verification times in milliseconds:
MD Val. cycle
Metadata validation cycle
MD Val. pure
Metadata validation pure
IL Ver. cycle
Microsoft intermediate language (MSIL) verification cycle
IL Ver pure
MSIL verification pure

The MD Val. cycle and IL Ver. cycle times include the time required to perform necessary startup and shutdown procedures. The MD Val. pure and IL Ver pure times reflect the time required to perform the validation or verification only.

/help Displays command syntax and options for the tool.
/hresult Displays error codes in hexadecimal format.
/ignore=hex.code [, hex.code] Ignores the specified error codes.
/ignore=@responseFile Ignores the error codes listed in the specified response file.
/il Performs MSIL type safety verification checks for methods implemented in the assembly specified by filename. The tool returns detailed descriptions for each problem found unless you specify the /quiet option.
/md Performs metadata validation checks on the assembly specified by filename. This walks the full metadata structure within the file and reports all validation problems encountered.
/quiet Specifies quiet mode; suppresses output of the verification problem reports. Peverify.exe still reports whether the file is type safe, but does not report information on problems preventing type safety verification.
/unique Ignores repeating error codes.
/? Displays command syntax and options for the tool.

Remarks

The common language runtime relies on the type-safe execution of application code to help enforce security and isolation mechanisms. Normally, code that is not verifiably type safe cannot run, although you can set security policy to allow the execution of trusted but unverifiable code.

If neither the /md nor /il options are specified, Peverify.exe performs both types of checks. Peverify.exe performs /md checks first. If there are no errors, /il checks are made. If you specify both /md and /il, /il checks are made even if there are errors in the metadata. Thus, if there are no metadata errors, peverify filename is equivalent to peverify filename /md /il.

Peverify.exe performs comprehensive MSIL verification checks based on dataflow analysis plus a list of several hundred rules on valid metadata. For detailed information on the checks Peverify.exe performs, see the "Metadata Validation Specification" and the "MSIL Instruction Set Specification" in the .NET Framework SDK's "Tools Developers Guide" folder.

Examples

The following command performs metadata validation checks and MSIL type safety verification checks for methods implemented in the assembly myAssembly.exe.

peverify myAssembly.exe /md /il

Upon successful completion of the above request, Peverify.exe displays the following message.

All classes and methods in myAssembly.exe Verified

The following command performs metadata validation checks and MSIL type safety verification checks for methods implemented in the assembly myAssembly.exe. The tool displays the time required to perform these checks.

peverify myAssembly.exe /md /il /clock

Upon successful completion of the above request, Peverify.exe displays the following message.

All classes and methods in myAssembly.exe Verified
Timing: Total run     320 msec
        MD Val.cycle  40 msec
        MD Val.pure   10 msec
        IL Ver.cycle  270 msec
        IL Ver.pure   230 msec

The following command performs metadata validation checks and MSIL type safety verification checks for methods implemented in the assembly myAssembly.exe. Peverify.exe stops, however, when it reaches the maximum error count of 100. The tool also ignores the specified error codes.

peverify myAssembly.exe /break=100 /ignore=0x12345678,0xABCD1234

The following command produces the same result as the above previous example, but specifies the error codes to ignore in the response file ignoreErrors.rsp.

peverify myAssembly.exe /break=100 /ignore@ignoreErrors.rsp

The response file can contain a comma-separated list of error codes.

0x12345678, 0xABCD1234

Alternatively, the response file can be formatted with one error code per line.

0x12345678
0xABCD1234

See Also

.NET Framework Tools | Writing Verifiably Type-Safe Code | Type Safety and Security