This isn't legal according to the Partition II Metadata spec and according to Serge's most excellent book on IL. The problem isn't that it is static member of the <Module> type. That is fine and I've been handling them for months now.
The problem is that the TypeRef has a nil resolution scope and there is no EXPORTEDTYPE table in the assembly and this is the prime (only) module. A nil resolution scope implies the reference is to a type defined in the same module of the assembly in which the reference appears. (A resolution scope of '1' implies the reference is to a type defined in a different module in the same assembly.) But the type does not appear to be defined at all in the module. There is no EXPORTEDTYPES table in this module so there appears to be no type to which a TYPEREF could bind anyway, let alone to this type. BTW I'm having to answer via the web pages again because the listserv hasn't sent me any mail in two days. Soon I'll get a few hundred messages if experience is a judge. > -- Brent Rector, .NET Wise Owl > Demeanor for .NET - an obfuscation utility > http://www.wiseowl.com/Products/Products.aspx From: Ted Neward <[EMAIL PROTECTED]> Subject: Re: Partition II Metadata Spec question Content-Type: text/plain; charset="iso-8859-1" It is perfectly legal (but I can't quote the part of the spec that states it, although Lidin does) for a static method to be global--in this case, it is actually scoped by the singleton "<Module>" type that all modules implicitly have defined on their behalf by the runtime. So, if I understand your question correctly, this isn't an invalid TypeRef at all. Ted Neward {.NET || Java} Course Author & Instructor, DevelopMentor (http://www.develop.com) http://www.javageeks.com/tneward http://www.clrgeeks.com/tneward ----- Original Message ----- From: "Brent E. Rector" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, April 11, 2002 7:33 PM Subject: [DOTNET] Partition II Metadata Spec question > Using VS.NET, I created a MFC Application project. The *only* change I > made was to switch on the /CLR command line option (which then forces > you to turn a few others off). This produces a single module .EXE > managed assembly containing with managed code and unmanaged data. > PEVerify /MD states that the metadata is valid. The application even > runs successfully. However, upon inspection, there appears to be an > invalid TypeRef. ILDASM /ADV shows the following: > > TypeRef #17 (01000011) > ------------------------------------------------------- > Token: 0x01000011 > ResolutionScope: 0x00000000 > TypeRefName: COccManager > > Note the nil resolution scope. However, there is no EXPORTEDTYPE table > in this single-module assembly. The type CoccManager is also never > defined in the assembly. In fact, this type seems to only be referenced > once in the entire application. Here is the ILDASM for the reference. It > is a global function method parameter: > > Method #154 > ------------------------------------------------------- > MethodName: AfxEnableControlContainer (0600009A) > Flags : [Public] [Static] [ReuseSlot] [PinvokeImpl] > [HasSecurity] (00006016) > RVA : 0x000075ee > ImplFlags : [Native] [Unmanaged] [PreserveSig] > (00000085) > CallCnvntn: [DEFAULT] > ReturnType: CMOD_OPT > System.Runtime.CompilerServices.CallConvCdecl Void > 1 Arguments > Argument #1: Ptr ValueClass COccManager > CustomAttribute #1 (0c00007e) > ------------------------------------------------------- > CustomAttribute Type: 0a00000b > CustomAttributeName: > System.Security.SuppressUnmanagedCodeSecurityAttribute :: instance void > .ctor() > Length: 4 > Value : 01 00 00 00 > > < > ctor args: () > > How the heck I am suppose to resolve this TypeRef? Thanks in advance for > any clues? > > > You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.