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

MarshalAs(UnmanagedType. EXception

I have DLL (unmannaged code) , in this DLL I have some functions and
structures.
one of those functions is GetDataBaseStructure (GDS_Structure *str), the
structure definition is as following :

//// GDS - General Data Structure
typedef struct _T_GeneralTestsDatabase {
int argc;
char *argv[256];//*argv[]
int numberOfStructure; //number of structurs
LPVOID ArrayOfStructurs;//handle array of GDS or TS
} GDS_Structure;
I tring to define such a structure in C# but without succsseed:

[ StructLayout( LayoutKind.Sequential )]
public struct GENERAL_DATABASE_structure //GDS
{
public int argc;

// I G O T Error H E R E
[MarshalAs(UnmanagedType.LPStr, SizeConst=256 )]
public StringBuilder [] argv;//*argv[]

public int numberOfStructure;
// I G O T Error H E R E
[ MarshalAs(UnmanagedType.LPStruct)]
unsafe public void* ArrayOfStructurs;
}

I get an exception when try to execute the function :
GetDataBaseStructure (ref my_GENERAL_DATABASE_structure);

what is wrong how can I define such an unmanaged code in C# ?

Nov 17 '05 #1
0 1247

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

Similar topics

0
by: Bob | last post by:
I have an old project written in VC++ that I want to convert to C#. In the old project I have a structure that has an array within it that is predefined to be 10 elements long. Anyway, I had issues...
2
by: Mo | last post by:
Hi, i am trying to call unmanaged C++ DLL in my C# application i converted all the structures to be .net compatible (e.g TCHAR to string (including Marshal As) one of the functions i try to...
4
by: maxixi | last post by:
Hi, It is my first time to use C#, and i struggle with my code with wininet api. Declare API: public abstract class WinInet { StructLayout(LayoutKind.Sequential)] public struct...
0
by: Stanislav Simicek | last post by:
Hello, I've noticed that MC++ compiler (VS.NET 2003) marks "bool" type with MarshalAs(UnmanagedType.U1) attribute, even if System::Boolean is used. I would understand, why this happens for C++...
2
by: Michael Moreno | last post by:
Hello, I have a .Net DLL that I use as a COM Server. I would like to return a SafeArray of double to a VB 6 client. I have declared this interface Public Interface ITest ...
8
by: **Developer** | last post by:
Been reading some of the Marshal doc and am a little confused. Anyway, I've been using the following and it works OK. Public Declare Auto Function SHGetFolderPath Lib "shell32.dll" (ByVal hWnd...
2
by: Paul Harvey | last post by:
Hi, I have some VB6 code that calls unmanaged DLLs, and I am converting it to C#. There's a couple of structs I need to define. I've had no problems with this one: Public Type A sz(128) As...
3
by: O.B. | last post by:
Below is a program that shows a test for marshaling data from a byte array to a class structure. Unfortunately, there are two annoying problems (bugs?) that I can't seem to get around. The...
0
by: Charming12 | last post by:
Hi , I need to pass Dynamic Size in the statement Is there anyway to pass a dynamic value in sizeconst or is there any other statement likethis which can take dynamic Size. Help will be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.