This project is read-only.

Method does not exist.

Jan 5, 2011 at 1:18 AM


I fixed my module class problem but I still get the "Method does not exist" message from PeVerify


Microsoft (R) .NET Framework PE Verifier.  Version  4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

[IL]: Error: [V:\Tests\CSharp\StorageLayoutDeclarationTest\StorageLayoutDeclarationTest\bin\Debug\StorageImpl.dll : Implementation+ReadInstanceFromArchive-Closure-ClassLibrary1.Person::Read][mdToken=0x6000020] Method does not exist.
[IL]: Error: [V:\Tests\CSharp\StorageLayoutDeclarationTest\StorageLayoutDeclarationTest\bin\Debug\StorageImpl.dll : Implementation+ReadStructFromArchive-Closure-ClassLibrary1.Color::Read][mdToken=0x6000022] Method does not exist.
2 Error(s) Verifying V:\Tests\CSharp\StorageLayoutDeclarationTest\StorageLayoutDeclarationTest\bin\Debug\StorageImpl.dll



Despite that message ildasm shows the method definition in the respective class definition:


  .class /*02000006*/ auto ansi nested private 'ReadInstanceFromArchive-Closure-ClassLibrary1.Person'
         extends [mscorlib/*23000001*/]System.Object/*01000001*/
    .field /*0400000A*/ public class [ClassLibrary1/*23000002*/]ClassLibrary1.Person/*01000002*/ Self
    .method /*0600001F*/ public hidebysig specialname rtspecialname 
            instance void  .ctor(class [ClassLibrary1/*23000002*/]ClassLibrary1.Person/*01000002*/ self) cil managed
      // Code size       14 (0xe)
      .maxstack  8
      IL_0000:  ldarg.0
      IL_0001:  call       instance void [mscorlib/*23000001*/]System.Object/*01000001*/::.ctor() /* 0A000015 */
      IL_0006:  ldarg.0
      IL_0007:  ldarg.1
      IL_0008:  stfld      class [ClassLibrary1/*23000002*/]ClassLibrary1.Person/*01000002*/ Implementation/*02000002*//'ReadInstanceFromArchive-Closure-ClassLibrary1.Person'/*02000006*/::Self /* 0400000A */
      IL_000d:  ret
    } // end of method 'ReadInstanceFromArchive-Closure-ClassLibrary1.Person'::.ctor

    .method /*06000020*/ public hidebysig 
            instance void  Read(class [mscorlib/*23000001*/]System.IO.Stream/*01000007*/ 'stream') cil managed
      // Code size       35 (0x23)
      .maxstack  8
      IL_0000:  ldarg.0
      IL_0001:  ldfld      class [ClassLibrary1/*23000002*/]ClassLibrary1.Person/*01000002*/ Implementation/*02000002*//'ReadInstanceFromArchive-Closure-ClassLibrary1.Person'/*02000006*/::Self /* 0400000A */
      IL_0006:  ldarg.1
      IL_0007:  callvirt   string [PerPlexEd.Core/*23000005*/]PerPlexEd.StreamBinaryExtensions/*01000012*/::ReadBinaryString(class [mscorlib/*23000001*/]System.IO.Stream/*01000007*/) /* 0A000019 */
      IL_000c:  callvirt   instance void [ClassLibrary1/*23000002*/]ClassLibrary1.Person/*01000002*/::set_Name(string) /* 0A00000D */
      IL_0011:  ldarg.0
      IL_0012:  ldfld      class [ClassLibrary1/*23000002*/]ClassLibrary1.Person/*01000002*/ Implementation/*02000002*//'ReadInstanceFromArchive-Closure-ClassLibrary1.Person'/*02000006*/::Self /* 0400000A */
      IL_0017:  ldarg.1
      IL_0018:  callvirt   int32 [PerPlexEd.Core/*23000005*/]PerPlexEd.StreamBinaryExtensions/*01000012*/::ReadBinaryInt32(class [mscorlib/*23000001*/]System.IO.Stream/*01000007*/) /* 0A00001A */
      IL_001d:  callvirt   instance void [ClassLibrary1/*23000002*/]ClassLibrary1.Person/*01000002*/::set_Age(int32) /* 0A00000F */
      IL_0022:  ret
    } // end of method 'ReadInstanceFromArchive-Closure-ClassLibrary1.Person'::Read

  } // end of class 'ReadInstanceFromArchive-Closure-ClassLibrary1.Person'



The only other place where that metadata token is referenced is:

  .method /*06000009*/ public hidebysig static 
          void  ReadInstanceFromArchive(class [ClassLibrary1/*23000002*/]ClassLibrary1.Person/*01000002*/ self,
                                        class [PerPlexEd.Conserva/*23000003*/]PerPlexEd.Conserva.Archive/*01000005*/ archive,
                                        int64 index) cil managed
    // Code size       29 (0x1d)
    .maxstack  3
    .locals /*11000003*/ init (class Implementation/*02000002*//'ReadInstanceFromArchive-Closure-ClassLibrary1.Person'/*02000006*/ V_0,
             class [mscorlib/*23000001*/]System.Action`1/*0100000D*/ V_1)
    IL_0000:  ldarg.0
    IL_0001:  newobj     instance void Implementation/*02000002*//'ReadInstanceFromArchive-Closure-ClassLibrary1.Person'/*02000006*/::.ctor(class [ClassLibrary1/*23000002*/]ClassLibrary1.Person/*01000002*/) /* 0600001F */
    IL_0006:  stloc.0
    IL_0007:  ldloc.0
    IL_0008:  ldftn      instance void Implementation/*02000002*//'ReadInstanceFromArchive-Closure-ClassLibrary1.Person'/*02000006*/::Read(class [mscorlib/*23000001*/]System.IO.Stream/*01000007*/) /* 06000020 */
    IL_000e:  newobj     instance void class [mscorlib/*23000001*/]System.Action`1/*0100000D*//*1B000001*/::.ctor(object,
                                                                                                                                                                            native int) /* 0A000009 */
    IL_0013:  stloc.1
    IL_0014:  ldarg.1
    IL_0015:  ldarg.2
    IL_0016:  ldloc.1
    IL_0017:  callvirt   instance void [PerPlexEd.Conserva/*23000003*/]PerPlexEd.Conserva.Archive/*01000005*/::Get(int64,
                                                                                                       class [mscorlib/*23000001*/]System.Action`1/*0100000D*/) /* 0A00000B */
    IL_001c:  ret
  } // end of method Implementation::ReadInstanceFromArchive

So I guess that must be the offending code.

That said, I can't understand where is the problem. Do you have any suggestion?


Jan 5, 2011 at 1:48 AM

I can't even find a decent documentation source for PeVerify. All MSDN say the list of command line arguments.


Jan 5, 2011 at 6:03 AM

CCI metadata can re-load the generated assembly and the offending operation's value is the correct method definition.


Jan 5, 2011 at 6:24 AM

Nothing rings a bell, I'm afraid. If you can provide the assembly I can have a closer look. You might also try to cut down the size of the assembly until it verifies and then concentrate on the changes that made that happen. Another thing you can try is to ilasm the ildasm list and then seeing if the result verifies. Likewise, what happens after petope?

Jan 5, 2011 at 11:26 PM

Maybe it was clear to the rest of the world but 

[mdToken=0x6000020] Method does not exist.

doesn't mean that the method with metadata token 0x6000020 does not exist.

It means that in 0x6000020 there is a reference to a method tha does not exist.

Since in previous runs of PeVerify I was getting the exact offsets of the offending operation,

I completely misunderstood the error messages and was looking for the problem in the wrong place

(that is, the places where 0x6000020 is referenced).

The offending line was inside 0x6000020 and specifically this call to an extension method that

was performed as instance method call

IL_0007:  callvirt   string [PerPlexEd.Core/*23000005*/]PerPlexEd.StreamBinaryExtensions/*01000012*/::ReadBinaryString(class [mscorlib/*23000001*/]System.IO.Stream/*01000007*/) /* 0A000019 */

 They should really publish more documentation about PeVerify.

Thanks for trying to help.