Click here to Skip to main content
15,915,864 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Convert a String to a char array Pin
Tom Archer20-Jul-03 5:11
Tom Archer20-Jul-03 5:11 
GeneralRe: Convert a String to a char array Pin
Anthony_Yio24-Jul-03 22:29
Anthony_Yio24-Jul-03 22:29 
Generaldebug managed and unmanaged code Pin
jspano17-Jul-03 4:28
jspano17-Jul-03 4:28 
GeneralRe: debug managed and unmanaged code Pin
leppie17-Jul-03 7:37
leppie17-Jul-03 7:37 
GeneralRe: debug managed and unmanaged code Pin
jspano17-Jul-03 7:46
jspano17-Jul-03 7:46 
GeneralRe: debug managed and unmanaged code Pin
Nathan Blomquist17-Jul-03 9:45
Nathan Blomquist17-Jul-03 9:45 
GeneralRe: debug managed and unmanaged code Pin
leppie17-Jul-03 11:05
leppie17-Jul-03 11:05 
GeneralRe: debug managed and unmanaged code Pin
jspano18-Jul-03 4:14
jspano18-Jul-03 4:14 
OK Now I have the StackOverflow problem that I thought I had solved. Nathan, it's the one we talked about before, leppie it's about 10 posts down.

I have the following code.

<br />
void CAES::EncryptStr(String* EncString, StringBuilder* Buff)<br />
	{<br />
		wchar_t __nogc* pStr = (wchar_t*)(Marshal::StringToHGlobalUni(EncString)).ToPointer(); 		<br />
<br />
		int sz;<br />
		sz = ((wcslen(pStr) / 15) + 1) * 64; //every 16 chars you get another 64 bit block this makes it dynamic<br />
		wchar_t (*pBuff) = new wchar_t[sz];<br />
		int Ret;<br />
		<br />
<br />
		Ret = EncryptString(pStr,pBuff);<br />
<br />
		Buff->Remove(0,Buff->Length); // this clears the StringBuilder	<br />
		if(Ret != -1)<br />
		{<br />
			Buff->Append(new String(pBuff)); // adds the result to the StringBuilder	<br />
		}<br />
			<br />
		delete [] pBuff;<br />
		Marshal::FreeHGlobal((int)pStr);<br />
	}<br />


I have a vb.net project that I put a call to this function in. I pass it a String set to "Hello" and a empty stringbuilder.


On this line: wchar_t (*pBuff) = new wchar_t[sz];
I get the error:An unhandled exception of type 'System.StackOverflowException' occurred in jjutility.dll

on this line. I got this error before, and modified the code to what is above. The error went away. Now it's back. I can't think of anything else I have changed.

It might not be a MC problem though. I am pretty rusty at C++. haven't used it in a while.

I also found that the problem is with the code
int sz;<br />
		sz = ((wcslen(pStr) / 15) + 1) * 64; //every 16 chars you get another 64 bit block this makes it dynamic<br />
		wchar_t (*pBuff) = new wchar_t[sz];

and doesn't matter what comes before it.
the line wchar_t (*pBuff) = new wchar_t[sz]; errors no matter what I use for sz, be it the sz variable or a hardcoded number.

Have I been staring at this too long and missed something simple??
GeneralRe: debug managed and unmanaged code Pin
jspano18-Jul-03 8:58
jspano18-Jul-03 8:58 
GeneralRe: debug managed and unmanaged code Pin
leppie18-Jul-03 13:13
leppie18-Jul-03 13:13 
GeneralRe: debug managed and unmanaged code Pin
jspano18-Jul-03 15:56
jspano18-Jul-03 15:56 
GeneralRe: debug managed and unmanaged code Pin
jspano18-Jul-03 16:41
jspano18-Jul-03 16:41 
GeneralRe: debug managed and unmanaged code Pin
jspano18-Jul-03 8:56
jspano18-Jul-03 8:56 
GeneralRe: debug managed and unmanaged code Pin
Nathan Blomquist21-Jul-03 1:58
Nathan Blomquist21-Jul-03 1:58 
GeneralRe: debug managed and unmanaged code Pin
jspano21-Jul-03 2:05
jspano21-Jul-03 2:05 
QuestionHow To Efficiently Copy Int32 to unsigned char __gc [] Pin
T R B16-Jul-03 5:56
T R B16-Jul-03 5:56 
AnswerRe: How To Efficiently Copy Int32 to unsigned char __gc [] Pin
Italo Silveira16-Jul-03 7:00
Italo Silveira16-Jul-03 7:00 
GeneralRe: How To Efficiently Copy Int32 to unsigned char __gc [] Pin
T R B16-Jul-03 7:05
T R B16-Jul-03 7:05 
GeneralStoring a static dictionary of class instances Pin
Jeremy Osner15-Jul-03 5:36
Jeremy Osner15-Jul-03 5:36 
GeneralRe: Typos Pin
Jeremy Osner15-Jul-03 6:19
Jeremy Osner15-Jul-03 6:19 
GeneralRe: Storing a static dictionary of class instances Pin
Jeremy Osner15-Jul-03 6:34
Jeremy Osner15-Jul-03 6:34 
GeneralRule of Three for Managed C++ Pin
mond_m15-Jul-03 4:54
sussmond_m15-Jul-03 4:54 
GeneralRe: Rule of Three for Managed C++ Pin
Tom Archer18-Jul-03 7:38
Tom Archer18-Jul-03 7:38 
Generaldate class problem Pin
Forever8214-Jul-03 21:55
Forever8214-Jul-03 21:55 
QuestionHOW TO MAKE A SIMPLE C SOLUTION Pin
eggie513-Jul-03 14:50
eggie513-Jul-03 14:50 

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.