473,385 Members | 1,320 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,385 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 6560
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.