473,387 Members | 1,585 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,387 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 2004
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
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...

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.