Click here to Skip to main content
15,889,595 members
Home / Discussions / C#
   

C#

 
GeneralRe: ListBox throwing a "Not valid value"-exception Pin
Gadjuka9-Jun-08 20:02
Gadjuka9-Jun-08 20:02 
GeneralRe: ListBox throwing a "Not valid value"-exception Pin
#realJSOP10-Jun-08 0:10
mve#realJSOP10-Jun-08 0:10 
QuestionSortedDictionary v.s. Dictionary Pin
George_George8-Jun-08 22:41
George_George8-Jun-08 22:41 
AnswerRe: SortedDictionary v.s. Dictionary Pin
leppie9-Jun-08 3:43
leppie9-Jun-08 3:43 
GeneralRe: SortedDictionary v.s. Dictionary Pin
George_George9-Jun-08 16:57
George_George9-Jun-08 16:57 
QuestionX509Store from file Pin
komadich8-Jun-08 22:40
komadich8-Jun-08 22:40 
GeneralRe: X509Store from file Pin
telha9-Jun-08 0:40
telha9-Jun-08 0:40 
QuestionEncoding problem with string from DLL Pin
steve_rm8-Jun-08 21:46
steve_rm8-Jun-08 21:46 
Hello,

VS 2008 3.5.Net

I am getting a string from a call back in a C++ native DLL which I have written. And for some reason it displays wrong something like this. i.e. [][[[[[[[[[[[[[ or ????????????????? with ASCII encoding.

My code is below. I think the DLL is using unicode, and I am trying to encode it in ASCII. The parameter in call back definition is char*. And in my C# I am using a string.

I have also tried Unicode, UTF-8, and ASCII. All of them display incorrectly.

Am I doing something wrong with my code?

Many thanks for any suggestions,

<br />
*.hpp file ==============<br />
typedef int (__stdcall *ptrIncomingCall)(int callID, char *caller);<br />
MOBILEDLL_API int drvIncomingCall(ptrIncomingCall cb);<br />
<br />
*.cpp file ==============<br />
int drvIncomingCall(ptrIncomingCall cb)<br />
{<br />
	int callerID = cb(20, "Joe bloggs");<br />
<br />
	return callerID;<br />
}<br />
<br />
C# code ===============<br />
 private delegate int incomingCallDelegate(int callerID, string caller);<br />
        [DllImport("MobileDLL.dll")]<br />
        static extern int drvIncomingCall(incomingCallDelegate cb);<br />
<br />
        int OnIncomingCall(int callerID, string caller)<br />
        {<br />
            ASCIIEncoding encoding = new ASCIIEncoding();<br />
            byte[] callerBytes = encoding.GetBytes(caller);<br />
<br />
            this.label1.Text = callerID.ToString();<br />
            this.label2.Text = encoding.GetString(callerBytes, 0, callerBytes.Length);<br />
<br />
            return 1;<br />
        }<br />
<br />
        private void button4_Click(object sender, EventArgs e)<br />
        {<br />
            drvIncomingCall((incomingCallDelegate)OnIncomingCall);   <br />
        }<br />

AnswerRe: Encoding problem with string from DLL Pin
ncjlee8-Jun-08 21:56
ncjlee8-Jun-08 21:56 
QuestionRe: Encoding problem with string from DLL Pin
steve_rm9-Jun-08 1:45
steve_rm9-Jun-08 1:45 
AnswerRe: Encoding problem with string from DLL Pin
ncjlee9-Jun-08 2:40
ncjlee9-Jun-08 2:40 
QuestionRe: Encoding problem with string from DLL Pin
steve_rm9-Jun-08 16:33
steve_rm9-Jun-08 16:33 
Questioni want to upload all files from one folder( in client side) to server without browse option Pin
md_azy8-Jun-08 21:30
md_azy8-Jun-08 21:30 
AnswerRe: i want to upload all files from one folder( in client side) to server without browse option Pin
Guffa8-Jun-08 21:33
Guffa8-Jun-08 21:33 
GeneralRe: i want to upload all files from one folder( in client side) to server without browse option Pin
md_azy9-Jun-08 1:29
md_azy9-Jun-08 1:29 
GeneralRe: i want to upload all files from one folder( in client side) to server without browse option Pin
Guffa9-Jun-08 6:38
Guffa9-Jun-08 6:38 
QuestionHow to remove zero using Regx Pin
Exelioindia8-Jun-08 21:27
Exelioindia8-Jun-08 21:27 
AnswerRe: How to remove zero using Regx Pin
Exelioindia8-Jun-08 21:47
Exelioindia8-Jun-08 21:47 
GeneralRe: How to remove zero using Regx Pin
ncjlee8-Jun-08 22:04
ncjlee8-Jun-08 22:04 
QuestionPloblem about multithread programing? Pin
abcomp018-Jun-08 21:26
abcomp018-Jun-08 21:26 
AnswerRe: Ploblem about multithread programing? Pin
ncjlee8-Jun-08 21:38
ncjlee8-Jun-08 21:38 
Questiongetting xml data from previous form Pin
laziale8-Jun-08 21:16
laziale8-Jun-08 21:16 
AnswerRe: getting xml data from previous form Pin
Ajay.k_Singh8-Jun-08 23:19
Ajay.k_Singh8-Jun-08 23:19 
Questionbit parameter problem Pin
Mr.Kode8-Jun-08 20:52
Mr.Kode8-Jun-08 20:52 
QuestionRe: bit parameter problem Pin
Vasudevan Deepak Kumar8-Jun-08 21:15
Vasudevan Deepak Kumar8-Jun-08 21:15 

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.