Click here to Skip to main content
15,891,657 members
Home / Discussions / C#
   

C#

 
QuestionHTML vriable to C# Pin
ytubis2-Mar-06 11:36
ytubis2-Mar-06 11:36 
AnswerRe: HTML vriable to C# Pin
Curtis Schlak.2-Mar-06 12:24
Curtis Schlak.2-Mar-06 12:24 
GeneralRe: HTML vriable to C# Pin
ytubis2-Mar-06 12:38
ytubis2-Mar-06 12:38 
GeneralRe: HTML vriable to C# Pin
Curtis Schlak.2-Mar-06 13:21
Curtis Schlak.2-Mar-06 13:21 
QuestionVSTO Excel buttons Pin
Drew McGhie2-Mar-06 11:30
Drew McGhie2-Mar-06 11:30 
Question"unable to setablish connection to network" exception Pin
amresawy2-Mar-06 10:11
amresawy2-Mar-06 10:11 
AnswerRe: "unable to setablish connection to network" exception Pin
Vasudevan Deepak Kumar2-Mar-06 21:08
Vasudevan Deepak Kumar2-Mar-06 21:08 
QuestionCall C# DLL from unmanaged C++: question on string Pin
Koushik Biswas2-Mar-06 10:05
Koushik Biswas2-Mar-06 10:05 
I have written a C# DLL that I intend to call from an unmanaged C++ app. I have so far followed all the rules that Microsoft explains in this article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcwlkcominteroppart2cservertutorial.asp[^]. My ultimate goal is to have a method in the C# DLL which will populate a string OUT parameter, and call it from C++. Something like void GetErrorString( int iErrorCode, ref string szErrorString ). Now do not take that signature seriously - because that is what the question is! What should be the signature???? And how exactly do I call it from C++?

So far I have tried:

Attempt 1.
C# signature:
void Func2( int iCode, ref char [] szOut );
C++ call:
char szRetString[ 128 ];<br />
cpi->Func2( 10, &szRetString );

Result: Runtime error
Variation: Instead of "&szRetString" in C++, tried "szRetString". Same result.
Variation: Instead of "ref" in C#, tried without ref. Same result.

Attempt 2.
C# signature:
void Func2( int iCode, ref string szOut );
C++ call:
char szRetString[ 128 ];<br />
cpi->Func2( 10, &szRetString );

Result: Runtime error
Variation: Instead of "&szRetString" in C++, tried "szRetString". Same result.
Variation: Instead of "ref" in C#, tried without ref. Same result.

Attempt 3.
C# signature:
void Func2( int iCode, ref StringBuilder szOut );
C++ call:
char szRetString[ 128 ];<br />
cpi->Func2( 10, &szRetString );

Result: Runtime error
Variation: Instead of "&szRetString" in C++, tried "szRetString". Same result.
Variation: Instead of "ref" in C#, tried without ref. Same result.

And all the cross-variations of the above combinations as well!!!!

Can somebody please tell me where am I going wrong? My C++ project does not have UNICODE defined. But please note that I have succeeded in calling the example provided by the MSDN article (link above) - which means I am successful in sending a read - only copy of string as IN parameter into C#.

Ever wondered that microsoft examples avoid the harder part?;)


Koushik Biswas

-- modified at 16:06 Thursday 2nd March, 2006
QuestionRegex and Replace Pin
eggsovereasy2-Mar-06 9:39
eggsovereasy2-Mar-06 9:39 
AnswerRe: Regex and Replace Pin
Guffa2-Mar-06 9:44
Guffa2-Mar-06 9:44 
GeneralRe: Regex and Replace Pin
eggsovereasy2-Mar-06 9:50
eggsovereasy2-Mar-06 9:50 
GeneralRe: Regex and Replace Pin
Nadia Monalisa2-Mar-06 10:04
Nadia Monalisa2-Mar-06 10:04 
GeneralRe: Regex and Replace Pin
Paul Conrad2-Mar-06 18:51
professionalPaul Conrad2-Mar-06 18:51 
Questionextracting values of meta tags in html Pin
rizwan_rashid2-Mar-06 9:19
rizwan_rashid2-Mar-06 9:19 
QuestionDisplaying an xml file on the Command Prompt Pin
Rajareet2-Mar-06 9:01
Rajareet2-Mar-06 9:01 
QuestionSerial Communications Pin
McSmack2-Mar-06 7:29
McSmack2-Mar-06 7:29 
Question"unable to connect to remtoe server" error Pin
amresawy2-Mar-06 7:11
amresawy2-Mar-06 7:11 
AnswerRe: Reading data from sound card Pin
Dan Neely2-Mar-06 7:11
Dan Neely2-Mar-06 7:11 
GeneralRe: Reading data from sound card Pin
Dan Neely2-Mar-06 7:44
Dan Neely2-Mar-06 7:44 
Question"Cannot implicitly convert ... " kind of error Pin
Pete Madden2-Mar-06 6:02
Pete Madden2-Mar-06 6:02 
AnswerRe: "Cannot implicitly convert ... " kind of error Pin
leppie2-Mar-06 6:19
leppie2-Mar-06 6:19 
GeneralRe: "Cannot implicitly convert ... " kind of error Pin
Pete Madden2-Mar-06 6:21
Pete Madden2-Mar-06 6:21 
QuestionFinding MousePointer in WinForms Pin
VenkataRamana.Gali2-Mar-06 5:35
VenkataRamana.Gali2-Mar-06 5:35 
GeneralRe: Finding MousePointer in WinForms Pin
Koushik Biswas2-Mar-06 10:18
Koushik Biswas2-Mar-06 10:18 
GeneralRe: Finding MousePointer in WinForms Pin
leppie2-Mar-06 23:02
leppie2-Mar-06 23:02 

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.