473,404 Members | 2,174 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,404 software developers and data experts.

Another c header conversion. Please help !

Hi all,

I'm trying to convert a long c header file with a lot of structs to c# and
I'm getting the following error:

An unhandled exception of type 'System.TypeLoadException' occurred in
Unknown Module.
Additional information: Could not load type
......because it contains an object field at offset 0 that is incorrectly
aligned or overlapped by a non-object field.

There's a lot of others structs but it's very similar with the following
ones. Any help to convert in C# be apreciated !

TIA,

--
Andre

-------------------------------------------------------
// Win32 Specific definitions for Windows/NT 3.5
#pragma pack(8)
typedef unsigned long Handle_t;
typedef unsigned char Boolean;
#define _Int int

typedef unsigned long InvokeID_t;
typedef char DeviceID_t[64];
typedef long RoutingCrossRefID_t;
typedef long RouteRegisterReqID_t;

typedef struct
{

InvokeID_t invokeID;
union
{
CSTARouteRequestEvent_t routeRequest;
CSTARouteRequestExtEvent_t routeRequestExt;
CSTAReRouteRequest_t reRouteRequest;
CSTAEscapeSvcReqEvent_t escapeSvcReqeust;
CSTASysStatReqEvent_t sysStatRequest;
} u;

} CSTARequestEvent;

typedef struct CSTARouteRequestEvent_t {
RouteRegisterReqID_t routeRegisterReqID;
RoutingCrossRefID_t routingCrossRefID;
DeviceID_t currentRoute;
DeviceID_t callingDevice;
ConnectionID_t routedCall;
SelectValue_t routedSelAlgorithm;
Boolean priority;
SetUpValues_t setupInformation;
} CSTARouteRequestEvent_t;

typedef struct ConnectionID_t {
long callID;
DeviceID_t deviceID;
ConnectionID_Device_t devIDType;
} ConnectionID_t;

typedef struct Connection_t {
ConnectionID_t party;
SubjectDeviceID_t staticDevice;
} Connection_t;

typedef struct ConnectionList_t {
_Int count;
Connection_t FAR *connection;
} ConnectionList_t;
--------------------------------------------------
Nov 17 '05 #1
2 2005
Hi,

Can you post one struct example?
"Andre Azevedo" wrote:
Hi all,

I'm trying to convert a long c header file with a lot of structs to c# and
I'm getting the following error:

An unhandled exception of type 'System.TypeLoadException' occurred in
Unknown Module.
Additional information: Could not load type
......because it contains an object field at offset 0 that is incorrectly
aligned or overlapped by a non-object field.

There's a lot of others structs but it's very similar with the following
ones. Any help to convert in C# be apreciated !

TIA,

--
Andre

-------------------------------------------------------
// Win32 Specific definitions for Windows/NT 3.5
#pragma pack(8)
typedef unsigned long Handle_t;
typedef unsigned char Boolean;
#define _Int int

typedef unsigned long InvokeID_t;
typedef char DeviceID_t[64];
typedef long RoutingCrossRefID_t;
typedef long RouteRegisterReqID_t;

typedef struct
{

InvokeID_t invokeID;
union
{
CSTARouteRequestEvent_t routeRequest;
CSTARouteRequestExtEvent_t routeRequestExt;
CSTAReRouteRequest_t reRouteRequest;
CSTAEscapeSvcReqEvent_t escapeSvcReqeust;
CSTASysStatReqEvent_t sysStatRequest;
} u;

} CSTARequestEvent;

typedef struct CSTARouteRequestEvent_t {
RouteRegisterReqID_t routeRegisterReqID;
RoutingCrossRefID_t routingCrossRefID;
DeviceID_t currentRoute;
DeviceID_t callingDevice;
ConnectionID_t routedCall;
SelectValue_t routedSelAlgorithm;
Boolean priority;
SetUpValues_t setupInformation;
} CSTARouteRequestEvent_t;

typedef struct ConnectionID_t {
long callID;
DeviceID_t deviceID;
ConnectionID_Device_t devIDType;
} ConnectionID_t;

typedef struct Connection_t {
ConnectionID_t party;
SubjectDeviceID_t staticDevice;
} Connection_t;

typedef struct ConnectionList_t {
_Int count;
Connection_t FAR *connection;
} ConnectionList_t;
--------------------------------------------------

Nov 17 '05 #2
Here it is. I deleted the C header to compact the post.

-----------------------------------------------------------
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi, Pack=8)]
public struct cstaRequestEvent
{
public uint invokeId;
public cstaRequestEventDescription requestEventDescription;
}

[StructLayout(LayoutKind.Explicit, CharSet=CharSet.Ansi, Pack=8)]
public struct cstaRequestEventDescription
{
[FieldOffset(0)] public cstaRouteRequestEvent cstaRouteRequest;
[FieldOffset(0)] public cstaRouteRequestExtEvent cstaRouteRequestExt;
[FieldOffset(0)] public cstaReRouteRequestType cstaReRouteRequest;
[FieldOffset(0)] public cstaEscapeSvcReqEvent cstaEscapeSvcReq;
[FieldOffset(0)] public cstaSysStatReqEvent cstaSysStatReq;
}

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi, Pack=8 )]
public struct cstaRouteRequestEvent
{
public int routeRegisterReqID;
public int routingCrossRefID;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=64)]
public string currentRoute;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=64)]
public string callingDevice;
public ConnectionID routedCall;
public SelectValue routedSelAlgorithm;
[MarshalAs(UnmanagedType.Bool)]
public bool priority;
public SetUpValues setupInformation;
}

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi, Pack=8 )]
public struct ConnectionID
{
public uint callID;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=64)]
public string deviceID;
public ConnectionID_Device devIDType;
}

[StructLayout(LayoutKind.Sequential )]
public struct ConnectionList
{
public int count;
//public System.IntPtr PConnection; // Pointer to Connection -------->
Is this right ?
}

"Salvador" <Sa******@discussions.microsoft.com> wrote in message
news:4C**********************************@microsof t.com...
Hi,

Can you post one struct example?

Nov 17 '05 #3

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

Similar topics

9
by: soni29 | last post by:
hi, i have written the following code, still in the learning stage: #include<iostream.h> class CBox { public: // Constructor definition CBox(double lv, double bv = 1.0, double hv = 1.0) :...
19
by: Steven T. Hatton | last post by:
The short sample program listed below has some features that I find to be bad style. In particular, they fail to communicate the connection between names used in this program and the location in...
34
by: E. Robert Tisdale | last post by:
Please find attached the physical constants header file physical.h It defines conversion factors to mks units. It might be used like this: > cat main.cc #include<iostream>...
188
by: christopher diggins | last post by:
I have posted a C# critique at http://www.heron-language.com/c-sharp-critique.html. To summarize I bring up the following issues : - unsafe code - attributes - garbage collection -...
0
by: Andre Azevedo | last post by:
Hi all, I'm trying to convert a long c header file with a lot of structs to c# and I'm getting the following error: An unhandled exception of type 'System.TypeLoadException' occurred in...
5
by: MidSilence | last post by:
Hi all, I'm trying to convert a long c header file with a lot of structs to c# and I'm getting the following error: An unhandled exception of type 'System.TypeLoadException' occurred in...
2
by: DCC700 | last post by:
VS 2005 Converted Header causing error when publishing After converting from Visual Studio 2003 to 2005, I have had several issues with a header that is used throughout the project. The...
10
by: Scoots | last post by:
I have the following code snippit that the compiler just won't take (vc ++ 6). I want to make a map as a member variable inside a class. So I've put it into the header file, and it won't take it...
5
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I have a sub in vb.net that adds extra headers to a gridview and it works very well. however, i tried to translate it to c# and i'm getting the header inserting itself over the first datarows and...
4
by: quophyie | last post by:
Hi guys I''m a new C++ programmer and I am having a few problems with some structs that I have defined in my header file and want to use in my CPP file. The struct called "deck" is defined in a...
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
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
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...
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.