ExecutionEngineException problems

  • Thread starter Thread starter Magnus Ullberg
  • Start date Start date
M

Magnus Ullberg

How do i convert the following structure declaration from c++ to c#?

#pragma pack(push,1) //Byte alignment
struct TtsrPlayerInfo
{
int PlayerID;
int ChannelID;
char NickName[30];
int PlayerChannelPrivileges;
int PlayerPrivileges;
int PlayerFlags;
};
#pragma pack(pop)

I've tried adding the following line just above the struct but it doesnt
seem to help. When the code runs i get a ExecutionEngineException.
[StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential, Pack =
1)]

What i'm trying to do is to get data from an external DLL imported using
DLLImport. I can get data from other dll calls just fine as long as the data
structure doesn't contain a char[].

Thanks,
Magnus Ullberg
 
struct TtsrPlayerInfo
{
//construct
public TtsrPlayerInfo() { }

//params
public int PlayerID;
public int ChannelID;
public char NickName[30];
public int PlayerChannelPrivileges;
public int PlayerPrivileges;
public int PlayerFlags;
}

-dec
 
By the way...notice in my code there is no ; after the last }...this is
important if you missed it
 
Are you sure this is c# code?
I'm looking to convert this c++ code to c#..

decrypted said:
struct TtsrPlayerInfo
{
//construct
public TtsrPlayerInfo() { }

//params
public int PlayerID;
public int ChannelID;
public char NickName[30];
public int PlayerChannelPrivileges;
public int PlayerPrivileges;
public int PlayerFlags;
}

-dec

g said:
How do i convert the following structure declaration from c++ to c#?

#pragma pack(push,1) //Byte alignment
struct TtsrPlayerInfo
{
int PlayerID;
int ChannelID;
char NickName[30];
int PlayerChannelPrivileges;
int PlayerPrivileges;
int PlayerFlags;
};
#pragma pack(pop)

I've tried adding the following line just above the struct but it doesnt
seem to help. When the code runs i get a ExecutionEngineException.
[StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential, Pack =
1)]

What i'm trying to do is to get data from an external DLL imported using
DLLImport. I can get data from other dll calls just fine as long as the data
structure doesn't contain a char[].

Thanks,
Magnus Ullberg
 
Hi Magnus,

Why do you think it is not C# code?
What problem do you get?

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Reply-To: "Magnus Ullberg" <[email protected]>
| From: "Magnus Ullberg" <[email protected]>
| References: <[email protected]>
<#[email protected]>
| Subject: Re: ExecutionEngineException problems
| Date: Mon, 15 Sep 2003 08:23:42 -0500
| Lines: 57
| Organization: Area Consulting Group, Inc.
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: ky-owensboro1b-121.owboky.adelphia.net 24.52.178.121
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.csharp:184202
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Are you sure this is c# code?
| I'm looking to convert this c++ code to c#..
|
| | > struct TtsrPlayerInfo
| > {
| > //construct
| > public TtsrPlayerInfo() { }
| >
| > //params
| > public int PlayerID;
| > public int ChannelID;
| > public char NickName[30];
| > public int PlayerChannelPrivileges;
| > public int PlayerPrivileges;
| > public int PlayerFlags;
| > }
| >
| > -dec
| >
| > | > > How do i convert the following structure declaration from c++ to c#?
| > >
| > > #pragma pack(push,1) //Byte alignment
| > > struct TtsrPlayerInfo
| > > {
| > > int PlayerID;
| > > int ChannelID;
| > > char NickName[30];
| > > int PlayerChannelPrivileges;
| > > int PlayerPrivileges;
| > > int PlayerFlags;
| > > };
| > > #pragma pack(pop)
| > >
| > > I've tried adding the following line just above the struct but it
doesnt
| > > seem to help. When the code runs i get a ExecutionEngineException.
| > > [StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential,
Pack
| =
| > > 1)]
| > >
| > > What i'm trying to do is to get data from an external DLL imported
using
| > > DLLImport. I can get data from other dll calls just fine as long as
the
| > data
| > > structure doesn't contain a char[].
| > >
| > > Thanks,
| > > Magnus Ullberg
| > >
| > >
| > >
| >
| >
|
|
|
 
public char NickName[30];

Syntax error, bad array declarator. To declare a managed array the rank
specifier precedes the variable's identifier.

I apreciate the help, someone in interop found a solution to my problem.

Jeffrey Tan said:
Hi Magnus,

Why do you think it is not C# code?
What problem do you get?

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Reply-To: "Magnus Ullberg" <[email protected]>
| From: "Magnus Ullberg" <[email protected]>
| References: <[email protected]>
<#[email protected]>
| Subject: Re: ExecutionEngineException problems
| Date: Mon, 15 Sep 2003 08:23:42 -0500
| Lines: 57
| Organization: Area Consulting Group, Inc.
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: ky-owensboro1b-121.owboky.adelphia.net 24.52.178.121
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.csharp:184202
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Are you sure this is c# code?
| I'm looking to convert this c++ code to c#..
|
| | > struct TtsrPlayerInfo
| > {
| > //construct
| > public TtsrPlayerInfo() { }
| >
| > //params
| > public int PlayerID;
| > public int ChannelID;
| > public char NickName[30];
| > public int PlayerChannelPrivileges;
| > public int PlayerPrivileges;
| > public int PlayerFlags;
| > }
| >
| > -dec
| >
| > | > > How do i convert the following structure declaration from c++ to c#?
| > >
| > > #pragma pack(push,1) //Byte alignment
| > > struct TtsrPlayerInfo
| > > {
| > > int PlayerID;
| > > int ChannelID;
| > > char NickName[30];
| > > int PlayerChannelPrivileges;
| > > int PlayerPrivileges;
| > > int PlayerFlags;
| > > };
| > > #pragma pack(pop)
| > >
| > > I've tried adding the following line just above the struct but it
doesnt
| > > seem to help. When the code runs i get a ExecutionEngineException.
| > > [StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential,
Pack
| =
| > > 1)]
| > >
| > > What i'm trying to do is to get data from an external DLL imported
using
| > > DLLImport. I can get data from other dll calls just fine as long as
the
| > data
| > > structure doesn't contain a char[].
| > >
| > > Thanks,
| > > Magnus Ullberg
| > >
| > >
| > >
| >
| >
|
|
|
 
Oh yes, in C#, it should be like this:
public char [] NickName;

I am glad your problem got resolved.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Reply-To: "Magnus Ullberg" <[email protected]>
| From: "Magnus Ullberg" <[email protected]>
| References: <[email protected]>
<#[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: ExecutionEngineException problems
| Date: Tue, 16 Sep 2003 08:11:27 -0500
| Lines: 110
| Organization: Area Consulting Group, Inc.
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: ky-owensboro1b-121.owboky.adelphia.net 24.52.178.121
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.
phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.csharp:184538
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| public char NickName[30];
|
| Syntax error, bad array declarator. To declare a managed array the rank
| specifier precedes the variable's identifier.
|
| I apreciate the help, someone in interop found a solution to my problem.
|
| | >
| > Hi Magnus,
| >
| > Why do you think it is not C# code?
| > What problem do you get?
| >
| > Best regards,
| > Jeffrey Tan
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| > This posting is provided "as is" with no warranties and confers no
rights.
| >
| > --------------------
| > | Reply-To: "Magnus Ullberg" <[email protected]>
| > | From: "Magnus Ullberg" <[email protected]>
| > | References: <[email protected]>
| > <#[email protected]>
| > | Subject: Re: ExecutionEngineException problems
| > | Date: Mon, 15 Sep 2003 08:23:42 -0500
| > | Lines: 57
| > | Organization: Area Consulting Group, Inc.
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <[email protected]>
| > | Newsgroups: microsoft.public.dotnet.languages.csharp
| > | NNTP-Posting-Host: ky-owensboro1b-121.owboky.adelphia.net
24.52.178.121
| > | Path:
| >
|
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
| > phx.gbl!TK2MSFTNGP09.phx.gbl
| > | Xref: cpmsftngxa07.phx.gbl
| microsoft.public.dotnet.languages.csharp:184202
| > | X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| > |
| > | Are you sure this is c# code?
| > | I'm looking to convert this c++ code to c#..
| > |
| > | | > | > struct TtsrPlayerInfo
| > | > {
| > | > //construct
| > | > public TtsrPlayerInfo() { }
| > | >
| > | > //params
| > | > public int PlayerID;
| > | > public int ChannelID;
| > | > public char NickName[30];
| > | > public int PlayerChannelPrivileges;
| > | > public int PlayerPrivileges;
| > | > public int PlayerFlags;
| > | > }
| > | >
| > | > -dec
| > | >
| > | > | > | > > How do i convert the following structure declaration from c++ to
c#?
| > | > >
| > | > > #pragma pack(push,1) //Byte alignment
| > | > > struct TtsrPlayerInfo
| > | > > {
| > | > > int PlayerID;
| > | > > int ChannelID;
| > | > > char NickName[30];
| > | > > int PlayerChannelPrivileges;
| > | > > int PlayerPrivileges;
| > | > > int PlayerFlags;
| > | > > };
| > | > > #pragma pack(pop)
| > | > >
| > | > > I've tried adding the following line just above the struct but it
| > doesnt
| > | > > seem to help. When the code runs i get a ExecutionEngineException.
| > | > >
[StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential,
| > Pack
| > | =
| > | > > 1)]
| > | > >
| > | > > What i'm trying to do is to get data from an external DLL imported
| > using
| > | > > DLLImport. I can get data from other dll calls just fine as long
as
| > the
| > | > data
| > | > > structure doesn't contain a char[].
| > | > >
| > | > > Thanks,
| > | > > Magnus Ullberg
| > | > >
| > | > >
| > | > >
| > | >
| > | >
| > |
| > |
| > |
| >
|
|
|
 
Back
Top