System.StackOverflowException was unhandledhttp://forums.asp.net/t/1133281.aspx/1?System+StackOverflowException+was+unhandledFri, 13 Jul 2007 15:56:29 -040011332811802694http://forums.asp.net/p/1133281/1802694.aspx/1?System+StackOverflowException+was+unhandledSystem.StackOverflowException was unhandled <span style="font-size:10pt; font-family:Arial">Hi Hope you could answer the following question to me or lead me to the right direction.</span><span style="font-size:10pt; font-family:Arial">&nbsp;</span><span style="font-size:10pt; font-family:Arial">I have coded a project which uses </span><span style="font-size:10pt; font-family:'Courier New'">Marshal::AllocHGlobal as you know it allocates memory from the unmanged memory for char * and int.</span><span style="font-size:10pt; font-family:'Courier New'">&nbsp;</span><span style="font-size:10pt; font-family:'Courier New'">I also used </span><span style="font-size:8.5pt; font-family:Verdana"><a href="http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices.marshal.freehglobal.aspx">Marshal.FreeHGlobal</a> to free the memory. The program works fine the first time. And sometimes 2 3 4 5 times but eventually I get the above message.</span><span style="font-size:8.5pt; font-family:Verdana">&nbsp;</span><span style="font-size:10pt; color:blue; font-family:'Courier New'">char</span><span style="font-size:10pt; font-family:'Courier New'"> *chrVersionName = (<span style="color:blue">char</span>*)(Marshal::AllocHGlobal(17).ToPointer()); this is the code where sometimes the program dies..</span><span style="font-size:10pt; font-family:'Courier New'">&nbsp;</span><span style="font-size:10pt; font-family:'Courier New'">and this how I free the memory.</span><span style="font-size:10pt; font-family:'Courier New'">&nbsp;</span><span style="font-size:10pt; font-family:'Courier New'">Marshal::FreeHGlobal(IntPtr(chrVersionName));</span><span style="font-size:10pt; font-family:'Courier New'">&nbsp;</span><span style="font-size:10pt; font-family:'Courier New'">&nbsp;</span><span style="font-size:10pt; font-family:'Courier New'">Any suggestions what Im doing run?</span><span style="font-size:10pt; font-family:'Courier New'">&nbsp;</span><span style="font-size:10pt; font-family:'Courier New'">I am using Visual Studio .NET Frawork 2.0</span><span style="font-size:10pt; font-family:'Courier New'">&nbsp;</span><span style="font-size:10pt; font-family:'Courier New'">Microsoft Visual Studio 2005</span><span style="font-size:10pt; font-family:'Courier New'">Version 8.0.50727.762<span style="">&nbsp; </span>(SP.050727-7600)</span><span style="font-size:10pt; font-family:'Courier New'">Microsoft .NET Framework</span><span style="font-size:10pt; font-family:'Courier New'">Version 2.0.50727</span><span style="font-size:10pt; font-family:'Courier New'">&nbsp;</span><span style="font-size:10pt; font-family:'Courier New'">&nbsp;</span><span style="font-size:10pt; font-family:'Courier New'">Microsoft Visual C&#43;&#43; 2005<span style="">&nbsp;&nbsp; </span>77626-009-0000007-41932</span><span style="font-size:10pt; font-family:Arial">&nbsp;</span><span style="font-size:10pt; font-family:Arial">I hope you could help me..</span> <p>&nbsp;</p> 2007-07-13T15:56:29-04:00