473,486 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Managed C++ destructor bug?

I am having a problem using destructors in managed C++ and
would appreciate help in finding a solution.

Thanks

Mark

----------- Error and Test Code -------------------------

The linker throws this error when the code below is built:

testmanagedCxx error LNK2001: unresolved external
symbol "void __cdecl __CxxCallUnwindDtor(void (__thiscall*)
(void *),void *)" (?
__CxxCallUnwindDtor@@$$J0YAXP6EXPAX@Z0@Z)
// This is the main DLL file.

#include "stdafx.h"

#include "testmanagedCxx.h" // the header does not
contain any code

namespace testmanagedCxx
{
public __gc class Base
{
private:
String *s;
public:
Base() { s = new String(L"hello"); }
~Base() { s = 0; }
};

public __gc class Derived : public Base
{
public:
Derived() {}
~Derived() {}
};
}

Nov 16 '05 #1
2 1127
Hi Mark,

Thanks for your post. Based on my experience and research, this function is
implemented in msvcr70.dll (or msvcr71.dll). To resolve the problem, you
can explicitly linking the project to the CRT library (msvcrt.lib or
msvcrtd.lib, depending on your build flavour) by the following steps:

1. Right-click the project in the Solution Explorer, choose Properties.
2. Go to "Configuration Properties" -> "Linker" -> "Input".
3. Add msvcrt.lib (or msvcrtd.lib if it's a debug build) to the Additional
Dependencies property.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #2
Check:

http://groups.google.com/groups?q=__CxxCallUnwindDtor
"Mark" <mh*@yadayada.com> wrote in message
news:14****************************@phx.gbl...
I am having a problem using destructors in managed C++ and
would appreciate help in finding a solution.

Thanks

Mark

----------- Error and Test Code -------------------------

The linker throws this error when the code below is built:

testmanagedCxx error LNK2001: unresolved external
symbol "void __cdecl __CxxCallUnwindDtor(void (__thiscall*)
(void *),void *)" (?
__CxxCallUnwindDtor@@$$J0YAXP6EXPAX@Z0@Z)
// This is the main DLL file.

#include "stdafx.h"

#include "testmanagedCxx.h" // the header does not
contain any code

namespace testmanagedCxx
{
public __gc class Base
{
private:
String *s;
public:
Base() { s = new String(L"hello"); }
~Base() { s = 0; }
};

public __gc class Derived : public Base
{
public:
Derived() {}
~Derived() {}
};
}

Nov 16 '05 #3

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

Similar topics

4
672
by: Michael Kennedy [UB] | last post by:
Hi, I'm working on a project which makes use of COM in unmanaged C++. That unmanaged C++ is then wrapped in a managed C++ class. Finally, this managed C++ class is then consumed in a C#...
1
1213
by: Mark | last post by:
I am having a problem using destructors in managed C++ and would appreciate help in finding a solution. Thanks Mark ----------- Error and Test Code ------------------------- The linker...
3
1421
by: andrew.bell.ia | last post by:
Hi, I'm trying to put together some managed and unmanaged code. Everything works fine until the program exits, and I suppose the garbage collector runs to finalize things. Then I get: ...
2
1747
by: chuck rudolph | last post by:
The project that I am on is going to require me to mix managed and unmanaged code. I created a vc++ class library (.net) project bane TestLib. I inserted the following test code in testLib.h. The...
11
1932
by: Lloyd Dupont | last post by:
(not I use 2.0, so new return a "normal" pointer and gcnew return a managed one, my question below regarding new concern plain standart C++ allocator) - if I use the default new operator, are all...
7
2405
by: Adam | last post by:
I have a managed cpp wrapper. Im using this in a native dll as a static variable. I need to free this library when the dll is done being used. The perfect place to do this is DllMain for...
9
1320
by: Peter Oliphant | last post by:
I would assume in the following that 'instance' being set to 'nullptr' should cause the instance of myClass that was created to no longer have any pointers pointing to it, and therefore be...
4
2046
by: Maxwell | last post by:
Hello, Newbie question here for disposing of unmanaged resources in MC++.NET. I have a managed VS.NET 2003 MC++ wrapper class that wraps a unmanaged C++ dll. What I am trying to figure out is...
5
7036
by: Michael D. Reed | last post by:
I have legacy DLL code written in C++ that is essentially C code, an implementation of a set of formulas used in our industry. There are no DB or GUI interfaces, just exposed methods. I would...
3
1155
by: Greg | last post by:
In the following example, where is "n" allocated (e.g. managed heap?) ? public ref class N { .... .... } main() {
0
7105
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7180
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
7341
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...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.