Your attachement didn't get through unfortunately, but did you try:

UnmanagedMarshal um = UnmanagedMarshal.DefineLPArray(typeof(int));
um.ElementCount = count;
ParameterBuilder.SetMarshal(em);

Regards,
Jeroen

> -----Original Message-----
> From: Moderated discussion of advanced .NET topics. 
> [mailto:[EMAIL PROTECTED] On Behalf Of Peter Partch
> Sent: Wednesday, February 04, 2004 06:54
> To: [EMAIL PROTECTED]
> Subject: [ADVANCED-DOTNET] Reflection.Emit, 
> MarshalAsAttribute and dealing with SizeParamIndex
> 
> As an 'academic' exercise, I've attempted to create a COM 
> interop assembly
> using classes from the Reflection.Emit namespace. The problem 
> that I ran
> into was in specifying the
> SizeParamIndex for an LPArray.
> 
> The generated IL should look something like:
> 
>      .method public hidebysig newslot abstract virtual
>          instance void  SetArray([in] int32 count,
>         [in] int32[]  marshal([+0]) 'array') runtime managed 
> internalcall
> 
> but instead, the 2nd parameter looks like (note the missing 
> index argument):
> 
>     [in] int32[]  marshal([]) 'array') runtime managed internalcall
> 
> with an equivalent C# definition of:
> 
>     void SetArray( int count, [MarshalAs(UnmanagedType.LPArray,
> SizeParamIndex=0)] int[] array);
> 
> I've attached the simplest C# source file that will 
> demonstrate the Emit
> code (as far as I can take it). Any ideas on how to specify 
> the array size
> parameter index for the marshal keyword?
> 
> Peter Partch
> 
> 
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
> Some .NET courses you may be interested in:
> 
> NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles
> http://www.develop.com/courses/gaspdotnetls
> 
> View archives and manage your subscription(s) at 
> http://discuss.develop.com
> 
> 

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

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

Reply via email to