473,394 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

StackOverflowException after calling unmanaged ctor

**Newbie with managed C++**

I'm trying to wrap an unmanaged C++ class in a managed C++ class library.
When I instantiate the wrapper class it's ctor calls the ctor on the
unmanaged class and at that point I get the exception:
"An unhandled exception of type 'System.StackOverflowException' occurred in
suabwrapper.dll"

I have been able to reproduce this with an unmanaged class that is VERY
simple:
class CTest

{

public:

CTest(){ m_id = 1; }

~CTest(){}

int GetID(){ return m_id; };

private:

int m_id;

};

In my managed class I have a CTest* member that I assign to a new CTest() in
the managed class' ctor:

CSUABWrapper()

{

m_pTest = new CTest();

}



Once the CTest ctor is called (I can't step into the code for some reason) I
get the exception.
Anyone know what could be going on? Any ideas??

Thanks,
Steve

Nov 17 '05 #1
4 2226
Project settings are "Mixed Mode" with /noentry
linking with: mscoree.lib
also using: __DllMainCRTStartup@12

"SteveK" <as***@asdfasdfsd.com> wrote in message
news:uO****************@TK2MSFTNGP09.phx.gbl...
**Newbie with managed C++**

I'm trying to wrap an unmanaged C++ class in a managed C++ class library.
When I instantiate the wrapper class it's ctor calls the ctor on the
unmanaged class and at that point I get the exception:
"An unhandled exception of type 'System.StackOverflowException' occurred in suabwrapper.dll"

I have been able to reproduce this with an unmanaged class that is VERY
simple:
class CTest

{

public:

CTest(){ m_id = 1; }

~CTest(){}

int GetID(){ return m_id; };

private:

int m_id;

};

In my managed class I have a CTest* member that I assign to a new CTest() in the managed class' ctor:

CSUABWrapper()

{

m_pTest = new CTest();

}



Once the CTest ctor is called (I can't step into the code for some reason) I get the exception.
Anyone know what could be going on? Any ideas??

Thanks,
Steve

Nov 17 '05 #2
http://msdn.microsoft.com/library/de...omixedmode.asp



static int minitialize() {

int retval = 0;

try

{

__crt_dll_initialize();

}

catch(System::Exception* e)

{

Console::WriteLine(e);

retval = 1;

}

return retval;

}

static int mterminate() {

int retval = 0;

try

{

__crt_dll_terminate();

}

catch(System::Exception* e)

{

Console::WriteLine(e);

retval = 1;

}

return retval;

}









"SteveK" <as***@asdfasdfsd.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Project settings are "Mixed Mode" with /noentry
linking with: mscoree.lib
also using: __DllMainCRTStartup@12

"SteveK" <as***@asdfasdfsd.com> wrote in message
news:uO****************@TK2MSFTNGP09.phx.gbl...
**Newbie with managed C++**

I'm trying to wrap an unmanaged C++ class in a managed C++ class library. When I instantiate the wrapper class it's ctor calls the ctor on the
unmanaged class and at that point I get the exception:
"An unhandled exception of type 'System.StackOverflowException' occurred in
suabwrapper.dll"

I have been able to reproduce this with an unmanaged class that is VERY
simple:
class CTest

{

public:

CTest(){ m_id = 1; }

~CTest(){}

int GetID(){ return m_id; };

private:

int m_id;

};

In my managed class I have a CTest* member that I assign to a new

CTest() in
the managed class' ctor:

CSUABWrapper()

{

m_pTest = new CTest();

}



Once the CTest ctor is called (I can't step into the code for some
reason) I
get the exception.
Anyone know what could be going on? Any ideas??

Thanks,
Steve


Nov 17 '05 #3

Hi Steve,

How do we turn off managed class in MSVS 2003 .Net . I have the sam
problem of stack overflow error.
Regards,
Georgie

--
GVG7Posted from http://www.pcreview.co.uk/ newsgroup acces

Nov 17 '05 #4

Hi Steve,

How do we turn off managed class in MSVS 2003 .Net . I have the sam
problem of stack overflow error.
Regards,
Georgie

--
GVG7Posted from http://www.pcreview.co.uk/ newsgroup acces

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jesee | last post by:
I am reading Jeffrey Richter's book "Applied Microsoft .NET Framework programming",i came across "Exception handing". Page 405 says "If the stack overflow occurs within the CLR itself,your...
1
by: JohnnySparkles | last post by:
Hi All, I'm having a problem with a StackOverflowException in a managed class. The exception is thrown when I attempt to allocate an unmanaged char array inside the managed class. It appears...
8
by: Lars-Erik Aabech | last post by:
Hi! I've got an asp.net page that works for all users except one and that one user only gets the error with a certain parameter set to a certain value. (Same value as the others, but for this...
6
by: c676228 | last post by:
Hi all, I don't know what the exact meaning in my case for this exception to be thrown. When my program execute the following statement: item.NumPersonsOnTrxn = GetNumofPeoplePerTrxn(orderID,...
0
by: Filippo Bettinaglio | last post by:
Security problem running unmanaged code (.ocx control) in a windows from control hosted in IE6 Hi, I have design a windows from control which contain a .OCX in one of its forms....
1
by: Thomee Wright | last post by:
I'm having a problem with a pair of applications I'm developing. I have a server application which interacts with several instruments, and a client app which connects to the server and provides a...
12
by: daz_oldham | last post by:
Hi everyone As my expedition into OOP takes another shaky step, I now am getting the error: An unhandled exception of type 'System.StackOverflowException' occurred in xxx.dll. In my...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
4
by: archana | last post by:
Hiall i have derived class from process class and implemented one method in that i am starting process using this.start. Its giving me stackoverflowexception. Can anyone tell me why? ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.