473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to marshal a structure with a structure array inside?

Sirs

I have the foolowing structures in C
#define POLY_MAX 8 // Número máximo de lados em um polÃ*gon

typedef struct { // Um vértice do polÃ*gon
double u, v; // texture space coord
double sx, sy; // screen space coord
double x, y, z; // object space coord
} poly_vert

typedef struct { // um polÃ*gon
int n; // número de lado
poly_vert vert[POLY_MAX]
} poly

and I used this solution

C
[StructLayout(LayoutKind.Sequential, Pack=1)
public struct poly_ver
{
public Double u, v;
public Double sx, sy;
public Double x, y, z;
}

[StructLayout(LayoutKind.Sequential, Pack=1)
public struct poly // um polÃ*gon
{
public Int32 n; // número de lado
[MarshalAs(UnmanagedType.ByValArray, SizeConst=4)
public poly_vert[] vert
public poly (int N

n = N
vert = new poly_vert[4]

When I try to call this function in an exported Win32 DL
extern "C" __declspec(dllexport) int pmap_poly(poly *p, double ST[3][3])

C
[DllImport("ImageWarping.dll")
public static extern int pmap_poly(poly p, [In, Out] double[,] ST)

I get this error

An unhandled exception of type 'System.TypeLoadException' occurred in ImageWarpingClient.ex
Additional information: Can not marshal field vert of type poly: This type can not be marshaled as a structure field

Any help? How can I marshal the field vert

Thanks

Camil

Nov 16 '05 #1
1 6561
Camilo,

See http://www.dotnetinterop.com/faq/?q=...ithStructArray

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Camilo Telles | last post by:
Sirs I have the foolowing structures in C #define POLY_MAX 8 // Número máximo de lados em um polígon typedef struct { // Um vértice do polígon double u, v; // texture space coord...
8
by: Charles Law | last post by:
Can anyone suggest how I would marshal a variable length structure back from an API call. Specifically, I am looking at the WaitForDebugEvent function, which returns a DEBUG_EVENT structure. ...
2
by: twawsico | last post by:
I have a piece of code that needs to read the contents of a binary file (that I've created with another app) into an array of structures. The binary data in the file represents just a series of...
2
by: Ananas | last post by:
Hi, Please give me an idea how to send a static array from dll written on C++ to C# application. This is a C++ code: const SIGNATURE_LENGTH = 50; struct Info {
1
by: nicewenyan | last post by:
I want to pass a managed c# byte (8 bit) array into a unmanaged c++ function: extern "C" void AddData(unsigned int* data); I use P/Invoke on managed side to do the marshaling as following: ...
7
by: repekto.argosoft | last post by:
Hi, I'm working with Marshalling. I got an idea to pass an object to the Native side as a byte array i.e. as void* in terms of C. For example: I have a .NET structure Point that contains...
2
by: O.B. | last post by:
When using Marshal to copy data from a byte array to the structure below, only the first byte of the "other" array is getting copied from the original byte array. What do I need to specify to get...
0
by: RobbieJosefson | last post by:
I want to marshal a structure containing a variable length array which will be populated within a C++ dll. the structure is the following Public Structure myStructure{ Public int size;...
2
by: O.B. | last post by:
I have operation within a class that marshals the data into a byte array. Below are three different ways that work. Are there any downsides to using one over the the other? public virtual byte...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.