473,397 Members | 1,969 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,397 software developers and data experts.

P/invoke : Marshaling two-dimensional char array

2
hi,

I'm currently trying to deal with this struct from C lib using Platform invoke in C#.

Here is the C struct:

Expand|Select|Wrap|Line Numbers
  1. typedef struct
  2. {
  3.   short myshort;
  4.   char Message[MAX_MESSAGE][MAX_MESS_LEN];
  5. } mystruct;
  6.  
This structure is passed as an argument to many functions of the dll I'm exporting.

Here is the C# (marshaled) structure in progress:

Expand|Select|Wrap|Line Numbers
  1. [ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Ansi )]
  2. public struct mystruct
  3. {
  4.   public short myshort;
  5.   [MarshalAs(???)]
  6.   ???
  7. }
  8.  
So basically, could you help me defining the equivalent matrix... I guess i need to use marshaling also... Thanks a lot. I've been searching for days...
Oct 12 '06 #1
2 3395
kevou
2
[MarshalAs(UnmanagedType.ByValArray, SizeConst=MAX_MESSAGE * MAX_MESS_LEN)]
public char[] Message;
Oct 13 '06 #2
Hi Kevou,

Any success with it?
If yes,please send the code....
Dec 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: VM | last post by:
What's marshalling? I've had to use it extensively for a project but I don't know what it means. I tried to look for a definition in the Internet but I couldn't find anything that would explain...
1
by: Nadav | last post by:
Hi I am about to write a performance crutial system, I am considering writing this system based on native COM or unmanaged C++ exposed as CLI, Now, I Wonder... does exposing a native code through...
3
by: David Logan | last post by:
I have an application using sockets, and it uses the asynchronous method for receiving (and others, but receiving is the basic problem.) In short, I want: class someClass: Form {...
4
by: Charles Law | last post by:
Hi guys. I have two threads: a main thread and a background thread. Lots of stuff happens in the background thread that means I have to update several (lots) of controls on a form. It is...
5
by: Chris | last post by:
We are using SQLite.net in an application but getting a bottleneck at the data access layer (it has been profiled). This is clearly because p/invoke takes 5 to 10 times longer than it does calling...
2
by: Bob Gray | last post by:
Hi, Can anyone explain how P/Invoke is able to cast the 32-bit HANDLE value returned from CreateFile (for example) to a SafeFileHandle object? Have a look at this code snippet from the .NET...
23
by: Thomas Due | last post by:
Hi, I have a class which monitors a TCP socket. This will on occasion raise an event which can be handled by a GUI. Now, I am aware of the if(InvokeRequire) { EventHandler d = new...
8
by: ba.hons | last post by:
Hello, I have started to use an old WIN32 API to develop an application and am having trouble executing one of the DLL's methods. int ContactController(char *ipHostName, int port) I have my...
0
by: jpogorman | last post by:
Hello, I am trying to get c# custom marshaling working in a particular scenario but it does not appear to be working or not jumping into my marshaling class when I try to debug it. I am try to...
0
by: mike1reynolds | last post by:
In a background worker threads are MTA, while UI threads must be STA. Attempting to instantiate a form class in a background worker throws an exception, so invocation of a delegate is required. My...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.