473,396 Members | 1,995 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.

unmanaged structs in struct with c#

Hello everyone,

I can't get that to work and I don't know why.
Simplified I have the following structs (Just a snip):

typedef struct
{
char* name;
int type;
Parameters1 otherStruct;
Parameters2 otherStruct2;
unsigned int lastUsed;
} TestStruct,*PTestStruct;

typedef struct Parameters1
{
Parameters3 otherStruct3;
Parameters4 otherStruct4
}Parameters1;

.......

I tried this C# class for that:

[StructLayout(LayoutKind.Sequential)]
public class TestStruct
{
[MarshalAs(UnmanagedType.LPStr)] public string name;
public int type;
public Parameters1 otherStruct;
public Parameters2 otherStruct2
public uint lastUsed;
}
But it doesn't work.
Any idea what's going wrong here?
Thanks.

greetings juergen

Apr 13 '06 #1
2 1295
>But it doesn't work.

In what way is it failing?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Apr 14 '06 #2
In what way is it failing?


The application just terminates when I call the method that has this struct as parameter.

juergen
Apr 14 '06 #3

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

Similar topics

8
by: Don | last post by:
I have a third party C++ DLL that I am trying to use from C#. The specific function I am trying to use is declared in C++ as follows: ladybugConvertToMultipleBGRU32( LadybugContext ...
2
by: zDog | last post by:
I found a lot of information on passing data from C# to a C++ dll What I cannot find is a way to return C++ structs of TCHAR string data back to the C# managed code! typedef struct // C++ data...
1
by: Lee Crabtree | last post by:
I have several unmanaged struct types that I've created equivalent managed struct types for. How do I marshal the managed structs into their unmanaged versions and vice versa? Here's a quick...
6
by: Vincent Finn | last post by:
Hi, I have what I thought was a simple question but I can't find an answer. I need to access (create) unmanaged C++ classes in C#. They aren't COM and they aren't struct just simple classes. ...
1
by: jcteague | last post by:
What is the best way to get a set of unmanaged structs to C#. I have the following structs: typedef struct { unsigned char Angle; unsigned char Rayon; } StructPointPolaire;...
6
by: =?Utf-8?B?QWxleGFuZGVyZmU=?= | last post by:
Hi, I have a C# program that uses an unmanaged dll that has a function similar to the signature below : void f(out MyStruct arr, out int num); // num = actual array length returned The array...
2
by: jonpb | last post by:
Using .NET 3.5, I need to pass an array of structs as parameter to a C++ unmanaged function. The C++ dll stores some data in an unmanaged cache, the function writes the values into the array of...
0
by: mjaaland | last post by:
Hi! I've been working with DLLimports passing structs and various other parameters to unmanaged code. I had problems earlier sending pointer to structs to the unmanaged code, and this forum solved...
13
by: Andy Baker | last post by:
I am attempting to write a .NET wrapper in C# for an SDK that has been supplied as a .LIB file and a .h header file. I have got most of the functions to work but am really struggling with the...
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:
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.