Re: Howto: Passing 'C' Array From Unmanaged to Managed by Reference
- From: Mattias Sjögren <mattias.dont.want.spam@xxxxxxxx>
- Date: Sun, 10 Jul 2005 19:38:59 +0200
>See function declarations below:
>
>.NET DECLARATION:
>public bool GetInt([MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)]
>int[] NumArray, int size)
> NumArray[0] = 45; // This modification is not reflected in the unmanaged
>side!
>
>VC 6.0 C++:
> int NumArray[100];
> NumArray[0] = 78;
> m_SmartPointer->GetInt(&NumArray, 100);
> // NumArray[0] still is 78, thought it would of been 45?
>
>The above works for passing a 'C' array however altering the contents of the
>array in the managed code does not
>get reflected in the ummanaged side.
Did you try adding the Out attribute to the parameter?
public bool GetInt([In, Out, MarshalAs(UnmanagedType.LPArray,
SizeParamIndex=1)] int[] NumArray, int size)
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
.
- Follow-Ups:
- References:
- Prev by Date: Re: Getting CLSID and possibly MemberInfo from __ComObject...
- Next by Date: .NET COM Interop from ASP
- Previous by thread: Howto: Passing 'C' Array From Unmanaged to Managed by Reference
- Next by thread: Re: Howto: Passing 'C' Array From Unmanaged to Managed by Referenc
- Index(es):
Relevant Pages
|