Re: array of structures to unmanaged memory

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thank you for the reply.

I am trying to port some VB6 code that does work properly with this dll
The VB6 code passed in the array of Types ByRef
I tried ByVal and I get a stack overflow error

In regards to this posting, I did google this thread:

http://www.dotnet247.com/247reference/msgs/43/215864.aspx

The following quote is from that very long thread
<<<<
The marshaller cannot handle "embedded arrays of structures" and "variable
length structs". It can only handle embedded arrays of blittable types(int,
char etc) - as I illustrated in a previous post.
If you really want to use C# to pass such managed structures to unmanaged
code, you'll need to help the marshaller by passing as argument to the API,
a pointer to a buffer, that contains a copy of the managed struct fields you
marshalled using the Marshal.WriteXX methods. On return you need to copy the
buffer contents back to the managed structure using the Marshal.ReadXX


I am just surprised that I can't find a syntax in DotNet to marshal an array
of structures
the same way VB6 marshalled an array of types.

The un-managed function is buried in a Fortran dll that I do not have the
source for.

Am I missing something simple here?


.



Relevant Pages

  • Re: Marshal Structure containing arrays to function in DLL
    ... David Fort wrote: ... I'm struggling with the info in the System.Runtime.Interop namespace help ... Is an Array of Structures containing 2 fixed length Arrays a blittable type? ... don't see how a marshaller could figure that out. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Fastest way to pass large array to and from COM
    ... With reference types, the types have to be marshaled to the unmanaged ... With an array of reference types, an unmanaged interface thunk is ... >> reference type would be pointless, since the marshaller has to marshal ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Marshal.SizeOf
    ... I'm using it to send to a server application as a byte array. ... > The marshaller in .NETCF v1.0 can't marshal structures or classes with ... > containing the string, or you create a flat byte array for the entire ... >> public enum SyncType ...
    (microsoft.public.dotnet.framework.compactframework)
  • A caveat for all of you who need to use C++ COM objects that return VARIANT* (containing SAFEARRAYs)
    ... ....and you get safe array type mismatch exceptions from the marshaller. ... Then I noticed that the memory for the array was allocated in a relatively ... Changing the data allocation to use SafeArrayCreate solved the C# ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Write array from vb6 dll to a specified worksheet in Excel
    ... Just for variety, you can do something like the following in your VB6 code, where Arr is the array to be dumped to the worksheet with an upper left corner of the cell referenced by R. ... > Excel VBA Sub: ...
    (microsoft.public.excel.programming)