Hi Jb,

I've managed to track down the exception to the following block of
code:

                static GenericParameter GetGenericParameter (Type t,
ImportContext context)
                {
                        int pos = (int) t.GetType ().GetProperty
("GenericParameterPosition").GetValue (t, null);
                        if (GenericParameterOfMethod (t))
                                return 
context.GenericContext.Method.GenericParameters [pos]; //
It throws a null reference exception here because the
GenericContext.Method property is null
                        else
                                return 
context.GenericContext.Type.GenericParameters [pos];
                }

Here's the stack trace:

>       
> Mono.Cecil.dll!Mono.Cecil.ReflectionHelper.GetGenericParameter(System.Type t 
> = {Name = "T" FullName = null}, Mono.Cecil.ImportContext context = 
> {Mono.Cecil.ImportContext}) Line 176    C#
        Mono.Cecil.dll!Mono.Cecil.ReflectionHelper.ImportSystemType
(System.Type t = {Name = "T" FullName = null},
Mono.Cecil.ImportContext context = {Mono.Cecil.ImportContext}) Line
232 + 0xb bytes C#
        Mono.Cecil.dll!Mono.Cecil.ReflectionHelper.GetGenericType
(System.Type t = {Name = "List`1" FullName = null},
Mono.Cecil.TypeReference element =
{System.Collections.Generic.List`1}, Mono.Cecil.ImportContext context
= {Mono.Cecil.ImportContext}) Line 162 + 0x1b bytes     C#
        Mono.Cecil.dll!Mono.Cecil.ReflectionHelper.GetTypeSpec(System.Type t
= {Name = "List`1" FullName = null}, Mono.Cecil.ImportContext context
= {Mono.Cecil.ImportContext}) Line 204 + 0x11 bytes     C#
        Mono.Cecil.dll!Mono.Cecil.ReflectionHelper.ImportSystemType
(System.Type t = {Name = "List`1" FullName = null},
Mono.Cecil.ImportContext context = {Mono.Cecil.ImportContext}) Line
229 + 0xe bytes C#
        Mono.Cecil.dll!Mono.Cecil.ModuleDefinition.Import(System.Type type =
{Name = "List`1" FullName = null}) Line 230 + 0x31 bytes        C#
        LinFu.Reflection.Emit.dll!
LinFu.Reflection.Emit.MethodDefinitionExtensions.SetReturnType
(Mono.Cecil.MethodDefinition method = {Mono.Cecil.MethodDefinition},
System.Type returnType = {Name = "List`1" FullName = null}) Line 85 +
0xd bytes       C#

In the SetReturnType method, this is the call that leads to the NRE:


// Return type = List`1
actualReturnType = module.Import(returnType);



On Apr 1, 2:01 am, Jb Evain <[email protected]> wrote:
> Hey Philip,
>
> On 3/31/09, Philip_L <[email protected]> wrote:
>
> >  Yes, I'm using the SVN head. Do you get the same error on your end
> >  when you try to import an open generic type?
>
> Sadly, nope. I tried in two different configurations: importing in an
> assembly which already contains a reference to the type, and into
> another one which doesn't contain a reference to the type.
>
> Is there any way I can setup something to reproduce the exception?
>
> --
> Jb Evain  <[email protected]>


--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to