Click here to Skip to main content
15,909,896 members
Home / Discussions / C#
   

C#

 
SuggestionRe: Error: Calling C++ dll function in C# Pin
Richard MacCutchan21-Oct-12 21:59
mveRichard MacCutchan21-Oct-12 21:59 
GeneralRe: Error: Calling C++ dll function in C# Pin
taibc21-Oct-12 22:01
taibc21-Oct-12 22:01 
GeneralRe: Error: Calling C++ dll function in C# Pin
Richard MacCutchan21-Oct-12 22:55
mveRichard MacCutchan21-Oct-12 22:55 
GeneralRe: Error: Calling C++ dll function in C# Pin
taibc21-Oct-12 23:28
taibc21-Oct-12 23:28 
GeneralRe: Error: Calling C++ dll function in C# Pin
Richard MacCutchan21-Oct-12 23:34
mveRichard MacCutchan21-Oct-12 23:34 
GeneralRe: Error: Calling C++ dll function in C# Pin
taibc21-Oct-12 23:40
taibc21-Oct-12 23:40 
GeneralRe: Error: Calling C++ dll function in C# Pin
Richard MacCutchan21-Oct-12 23:41
mveRichard MacCutchan21-Oct-12 23:41 
GeneralRe: Error: Calling C++ dll function in C# Pin
taibc21-Oct-12 23:45
taibc21-Oct-12 23:45 
GeneralRe: Error: Calling C++ dll function in C# Pin
Richard MacCutchan22-Oct-12 0:08
mveRichard MacCutchan22-Oct-12 0:08 
GeneralRe: Error: Calling C++ dll function in C# Pin
Richard MacCutchan22-Oct-12 0:10
mveRichard MacCutchan22-Oct-12 0:10 
GeneralRe: Error: Calling C++ dll function in C# Pin
J4amieC22-Oct-12 0:25
J4amieC22-Oct-12 0:25 
GeneralRe: Error: Calling C++ dll function in C# Pin
Richard MacCutchan22-Oct-12 1:05
mveRichard MacCutchan22-Oct-12 1:05 
GeneralRe: Error: Calling C++ dll function in C# Pin
taibc22-Oct-12 0:37
taibc22-Oct-12 0:37 
GeneralRe: Error: Calling C++ dll function in C# Pin
Richard MacCutchan22-Oct-12 1:03
mveRichard MacCutchan22-Oct-12 1:03 
AnswerRe: Error: Calling C++ dll function in C# Pin
BobJanova22-Oct-12 4:20
BobJanova22-Oct-12 4:20 
GeneralRe: Error: Calling C++ dll function in C# Pin
taibc22-Oct-12 15:51
taibc22-Oct-12 15:51 
GeneralRe: Error: Calling C++ dll function in C# Pin
taibc22-Oct-12 16:43
taibc22-Oct-12 16:43 
GeneralRe: Error: Calling C++ dll function in C# Pin
taibc23-Oct-12 17:44
taibc23-Oct-12 17:44 
Hi BobJanova,

I resolved that error as your sugesstion. However, I am getting another error while trying to get the text value of a char array in C.

For example: I have a struct in C that inclue a char array like below:

C++
struct DGNElemText
{
   .....

   char text[1]; /*!< Actual text (length varies, \0   terminated*/ 

   ....
}


And the converted codes in C#:

C#
[StructLayout(LayoutKind.Sequential)]
public class DGNElemText
{
   .....

   IntPtr text; 
}


And I got the text value by using Marshal.PtrToStringAnsi(...). But I always received an empty text value. It is not expected value such as: "Hello", "abc123",...

I still got the same value when trying to use the another way:
C#
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1)]
public string text; 


Do you know why ?
AnswerRe: Error: Calling C++ dll function in C# Pin
taibc22-Oct-12 23:04
taibc22-Oct-12 23:04 
GeneralRe: Error: Calling C++ dll function in C# Pin
mphill474423-Oct-12 7:10
mphill474423-Oct-12 7:10 
GeneralRe: Error: Calling C++ dll function in C# Pin
taibc23-Oct-12 17:07
taibc23-Oct-12 17:07 
Questionsmall IRC Based command shell Pin
seangroves21-Oct-12 13:42
seangroves21-Oct-12 13:42 
AnswerRe: small IRC Based command shell Pin
Richard MacCutchan21-Oct-12 21:54
mveRichard MacCutchan21-Oct-12 21:54 
Questionelse if statement vs switch statement Pin
DeAd_HeAd21-Oct-12 12:18
DeAd_HeAd21-Oct-12 12:18 
AnswerRe: else if statement vs switch statement Pin
Richard Andrew x6421-Oct-12 14:52
professionalRichard Andrew x6421-Oct-12 14:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.