"An unhandled exception of type 'System.StackOverflowException'
occurred in my.dll"
I cannot find any recursive loops, the VS 2003 debugger just waits for
30 seconds or so after I hit F11 and then gives me the above dialog
box.
Question: Does anyone have a ZIP file of a complete example that
includes an actual unmanaged C++ class source code with a managed C++
class source code wrapper that I can use to test my environment? How
about the actual source code files and project file for the example
from part-1 of the migration guide?
Here is what my current code looks like ... this is being compiled
into a C++ DLL that is being called by a managed C++ DLL that is being
called by C#.
...
#include "stdafx.h"
#pragma unmanaged
class CppClass
{
public:
// constructor
CppClass() {}
// destructor
~CppClass() {}
// methods
void native_f() {}
};
#pragma managed
#using <mscorlib.dll>
using namespace System::Runtime::InteropServices;
using namespace System;
public __gc class m_MyClass
{
public:
m_MyClass()
{
m_session = new CppClass(); -- this function call is causing the
StackOverflow exception
}
~m_MyClass()
{
delete m_session;
}
private:
CppClass *m_session;
};
Say you had an unmanaged C++ class like this:
#include < windows.h >
class UnmanagedClass {
public:
LPCWSTR GetPropertyA();
void MethodB( LPCWSTR );
};
To wrap this with Managed C++ you would do this:
#include < windows.h >
#using < mscorlib.dll >
#using < System.dll >
#include < vcclr.h >
using namespace System;
class UnmanagedClass {
public:
LPCWSTR GetPropertyA();
void MethodB( LPCWSTR );
};
public __gc class ManagedClass {
public:
ManagedClass()
: m_Impl( new UnmanagedClass ) {}
~ManagedClass() {
delete m_Impl;
}
__property String* get_PropertyA() {
return new String( m_Impl->GetPropertyA());
}
void MethodB( String* theString ) {
const WCHAR __pin* str = PtrToStringChars( theString );
m_Impl->MethodB( str );
}
private:
UnmanagedClass* m_Impl;
};
Thanks,
Ulzii-
--------------------
> From: franklo...@yahoo.com (Frank Lopez)
> Newsgroups: microsoft.public.dotnet.languages.vc
> Subject: managed C++ wrapper around unmanaged C++ classes: causing
StackOverflow exception
> Date: 12 Jun 2003 21:47:16 -0700
> Organization: http://groups.google.com/
> Lines: 70
> Message-ID: <b68e0841.03061...@posting.google.com>
> NNTP-Posting-Host: 192.138.150.250
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: 8bit
> X-Trace: posting.google.com 1055479636 29344 127.0.0.1 (13 Jun 2003
04:47:16 GMT)
> X-Complaints-To: groups...@google.com
> NNTP-Posting-Date: 13 Jun 2003 04:47:16 GMT
> Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.co
m!newsfeed.frii.net!newsfeed.frii.net!140.99.99.194.MISMATCH!newsfeed1.easyn
ews.com!easynews.com!easynews!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supern
ews.com!postnews1.google.com!not-for-mail
> Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vc:25008
> X-Tomcat-NG: microsoft.public.dotnet.languages.vc
--
Ulzii Luvsanbat, Microsoft Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Jeff McKelvey
"Ulzii Luvsanbat [VCPP MSFT]" <ba...@online.microsoft.com> wrote in message
news:a9ZRti1N...@cpmsftngxa06.phx.gbl...
Jeff McKelvey
"Jeff McKelvey" <je...@mckelveyweb.com> wrote in message
news:u3YkIr6O...@TK2MSFTNGP11.phx.gbl...