You are doing things in the wrong order. You need to do

ldarg.0
call instance void [mscorlib]System.Object::.ctor()

before you access any instance fields of your class. Until the base
class constructor is run, the instance is considered uninitialized, and
all operations with instance members are unverifiable.

Thanks,
Serge
-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Zaslavskiy,
Dmitriy (IT)
Sent: Friday, March 03, 2006 9:59 AM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: [ADVANCED-DOTNET] Why is the following IL unverifyable

Why is the following IL unverifiable?
I can't see anything in (ecma335) that would make it such. In fact the
opposite it true:

***** From 1.8.1.4  *****
The verification algorithm shall treat the this
pointer as uninitialized unless the base class constructor has been
called. No operations can be performed on an uninitialized this except
for storing into and loading from the object's fields.
**************************

But peverify complains:

ConsoleApplication1.Program::.ctor][offset 0x0000000E][found
<uninitialized>
 ref ('this' ptr) 'ConsoleApplication1.Program'] Uninitialized item on
stack.

It seems to me this should be verifiable. Any thoughts?

  .method public hidebysig specialname rtspecialname 
          instance void  .ctor() cil managed
  {
    // Code size       22 (0x16)
    .maxstack  8
    IL_0000:  ldarg.0
    IL_0001:  ldc.i4.3
    IL_0002:  stfld      int32 ConsoleApplication1.Program::a
    IL_0007:  ldarg.0
    IL_0008:  ldfld      int32 ConsoleApplication1.Program::a
    IL_000z:  ldarg.0
    IL_0009:  stfld      int32 ConsoleApplication1.Program::b
    IL_000e:  ldarg.0
    IL_000f:  call       instance void [mscorlib]System.Object::.ctor()
    IL_0014:  nop
    IL_0015:  ret
  } // end of method Program::.ctor
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender.  Sender
does not waive confidentiality or privilege, and use is prohibited.

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to