473,396 Members | 2,011 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.

Interop with struct containing char**

Hi

I have unmanaged code with following struct

struct DirList
{
char **elements /* [] */ ;
int32 *attributes /* [] */ ;
int64 *mtime /* [] */ ;
int64 *fsize /* [] */ ;
int32 num_elements ;
} ;

and the func is


Result MSWSTDCALL FT_dirList(SessionHandle *handle,const char *remoteDirName,DirList **dirlist,NBTicket *nbticket) ;

The code returns the dir list and sets num_elements to the number of elements in the char **element.

In the managed code, the struct I have defined

public struct DirList
{
public strinng[] elements /* [] */ ;
public int[] attributes /* [] */ ;
public int[] mtime /* [] */ ;
public int[] fsize /* [] */ ;
public int num_elements;
} ;
and the func is

[DllImport("a10.dll")]
public static extern Result FT_dirList(ref SessionHandle handle, string remoteDirName, out IntPtr dirlist, IntPtr nbticket);


I am calling the func in C# as

result = Class1.FT_dirList(ref session, "/", out outptr1, IntPtr.Zero);

and then trying to convert outptr(of type IntPtr) to DirList

dirlst = (Class1.DirList)Marshal.PtrToStructure(outptr1, typeof(Class1.DirList));

I am getting the following exception


Mismatch has occurred between the runtime type of the array and the sub type recorded in the metadata.

Any1 having ne idea what to do?

Regards
Aditya
Mar 23 '07 #1
0 1182

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

Similar topics

16
by: Alfonso Morra | last post by:
Hi, I am at the end of my tether now - after spending several days trying to figure how to do this. I have finally written a simple "proof of concept" program to test serializing a structure...
2
by: beetle | last post by:
Hello, I'm storing data in several different binary tree's. The root node is located in a struct containing general data about the tree. struct lnode { char *fname; int nentry;
6
by: ~toki | last post by:
I'm triyng to use this function int result = NativeMethods.midiOutGetDevCaps( -1, ref pSI, (uint)Marshal.SizeOf(pSI) ); Docs say that pSI is a struct (below) typedef struct { WORD wMid;...
3
by: Rudy Velthuis | last post by:
Hello, Does anyone know how to create a struct that will marshal to the following C++ struct A, containing an array of the user defined String10 type: struct String10 { char SLen; char S;
1
by: Markus Stiller | last post by:
Hello I have struct and there is a union in. (C DLL). Could someone give me ideas how to do it? I just tried for a while but without success... thats the c code: typedef struct { unsigned int...
0
by: kagorami | last post by:
Q: How do you return a LPSTR from unmanaged code? A: Use a StringBuilder. What about this: public struct CSTRUCT { string return_value; } How do you get a LPSTR from unmanaged code when it...
6
by: Nataraj1978 | last post by:
I have a requirement to use a dll written in Visual C++ 6.0 in my C# application. In order to establish the link between my application and the dll, I have written a ATL COM Component in Visual...
5
by: jaso | last post by:
Hi, If have a structure of a database record like this: struct record { char id; char title; ... }; Is there some way to find out how many member variables there is in the struct and then...
25
by: SRR | last post by:
Consider the following code: #include <stdio.h> #include <string.h> struct test{ char a; } funTest( void ); int main( void ) {
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...

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.