TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
John Bullino
NA
1
0
Converting a C++ struct to an C# struct
Sep 29 2009 3:11 PM
Hello,
I am new to C# and have a problem implementing an unmanaged .dll into an C# project which needs managed code.
The .dll is already accepted and also the correct entry points are found, the last problem seems to been the conversion from an C++ struct to an C# struct.
Here is the C++ code:
typedef struct SymbolRequest {
WORD SecurityType;
BYTE ExchangeId;
char Symbol[20];
DWORD Flags;
} SymbolRequest;
Of course I have already tried it by my own for several days but it always throws an exception stating that something tries to write or read in secured memory --- I expect that my conversions are wrong. See what I got in C#:
[StructLayout(LayoutKind.Sequential)]
public struct SymbolRequestStruct
{
public short SecurityType;
public byte ExchangeId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string Symbol;
public uint Flags;
}
Something has to be wrong and it would be nice if someone can help me since I am having the problem since more than three days.
Thank you in advance.
JB
Reply
Answers (
1
)
encrypt url in asp.net
.NET 3.5 Console Application: Ping a Server