Questions tagged [peverify]

PEVerify is a tool that checks if .NET assemblies meet type safety requirements.

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.

32 questions
19
votes
1 answer

Why does this line cause a VerificationException when running under .NET 4?

Help me out folks - why does this code cause a VerificationException when run under .NET 4.0? public T parseEnum(string value, T defaultValue) { //Removing the following lines fixes the problem if (!typeof(T).IsEnum) throw new…
Lilith River
  • 16,204
  • 2
  • 44
  • 76
15
votes
4 answers

Is there an API for verifying the MSIL of a dynamic assembly at runtime?

When using Reflection.Emit to build an assembly at runtime, I'd like to verify the assembly MSIL before saving to disc. Like PEVerify but at runtime. Is there such an API?
Stephen Swensen
  • 22,107
  • 9
  • 81
  • 136
13
votes
1 answer

log4net doesn't pass verification when compiling

https://github.com/apache/log4net I am compiling log4net from the source above, but it doesn't pass verification: [IL]: Error: [log4net.dll : log4net.Plugin.RemoteLoggingServerPlugin::Attach][offset 0x00000029] Method is not visible. Code is…
NN_
  • 1,593
  • 1
  • 10
  • 26
12
votes
5 answers

Where can I download PEVerify.exe tool?

I ran into an InvalidProgramException. This article: http://support.microsoft.com/kb/312544/en-us Suggests I run PEVerify.exe, but I can't seem to find it. Do you know where I can get it from? Thanks.
Scott Langham
  • 58,735
  • 39
  • 131
  • 204
11
votes
1 answer

Is there a simple way to decode PEVerify errors and warnings?

Given PEVerify error and warning output such as that below, how does one track back to the offending class and interface names? Assume I am not a compiler author or IL magician. [MD]: Error: Class implements interface but not method…
bentayloruk
  • 4,060
  • 29
  • 31
11
votes
1 answer

Why does a program with a PEVerified Stack Overflow Scenario (maxstack) Not Crash the CLR?

I can write, compile and successfully run the following IL program with a .maxstack size set to 1 which is too low because the program has two values on the stack at one point in time (i.e. 2+2==4). This program does not crash in the CLR and…
John K
  • 28,441
  • 31
  • 139
  • 229
7
votes
1 answer

Verification error on unsafe c# return type using Peverify and ILVerify

I have run into this issue when verifying some code containing an unsafe method that returns a pointer. The example can be expressed as this: public class A { public static unsafe int* GetAnswer() { int fakeValue = 42; return…
miniwolf
  • 339
  • 1
  • 4
  • 19
6
votes
1 answer

Wrap IL into an assembly written on disk in C# / .NET Core?

I am creating a .NET method based on raw IL. I would like to wrap the stand-alone newly created method into a .NET assembly and write this assembly to disk as a foo.dll file in order to then feed this assembly to PEVerify or ILVerify. Indeed, those…
Joannes Vermorel
  • 8,976
  • 12
  • 64
  • 104
6
votes
2 answers

Why is this .Net IL not verifiable?

I have a bit of custom IL I wrote and it won't pass PEVerify. The error I get is $ peverify foo.exe Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.17929 Copyright (c) Microsoft Corporation. All rights reserved. [IL]: Error:…
Earlz
  • 62,085
  • 98
  • 303
  • 499
4
votes
1 answer

Can a .NET assembly be verified independently of any other assemblies it might reference?

In other words: For a .NET assembly to be verified, do any of the referenced assembly need to be read and analyzed too? What does PEVerify tool do?
tgiphil
  • 1,242
  • 10
  • 22
4
votes
2 answers

Why is this code failing to verify?

I have a compiler that builds and runs correctly, but PEVerify is calling it unverifiable at a certain point. After looking carefully at the error, the corresponding source code, and the ILDasm output for the point in question, I can't find the…
Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477
3
votes
1 answer

Avoiding BadImageFormatException when there is unmanaged code

I have a web service that throws a BadImageFormatException any time I try to run the service from Visual Studio. This answer to another question suggested running peverify against DLLs to see if there are any problems. While my web service's DLL…
Sarah Vessels
  • 30,930
  • 33
  • 155
  • 222
3
votes
1 answer

How to diagnose "Type load failed" from PEVerify

I'm working on a compiler that's producing bad output in certain cases of expanding generators. PEVerify simply says "Type load failed" without giving any explanation as to why. When I've seen this in the past, it's generally been because the…
Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477
3
votes
1 answer

Is PEVerify warning about duplicate methods wrong here?

I'm working on obfuscating an assembly and after obfuscation PEVerify issues the following error: [MD]: Error: Method has a duplicate, token=0x060035d8. [token:0x060035D5] [MD]: Error: Method has a duplicate, token=0x060035d5.…
Ivan Danilov
  • 14,287
  • 6
  • 48
  • 66
3
votes
3 answers

How can I investigate issues after obfuscation in .net?

I'm trying to obfuscate a library with ConfuserEx, but afterwards my app crashes with MissingMethodException with stack trace pointing to first usage of obfuscated class and method in question is the one that was renamed. I have no idea where its…
Ivan Danilov
  • 14,287
  • 6
  • 48
  • 66
1
2 3