473,405 Members | 2,379 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,405 software developers and data experts.

How to export a class that inherits from unmanaged exception class

In my unmanaged C++ app (VS 2005) I have written a class that inherits from
exception. I want to export this class from a library DLL, but the compiler
complains because exception is not itself exported. Any words of wisdom?

TIA - Bob
Oct 16 '06 #1
3 1315
On Mon, 16 Oct 2006 12:41:29 -0700, "Bob Altman" <rd*@nospam.nospamwrote:
>In my unmanaged C++ app (VS 2005) I have written a class that inherits from
exception. I want to export this class from a library DLL, but the compiler
complains because exception is not itself exported. Any words of wisdom?
You need to compile for the multithreaded DLL (/MD or /MDd).

--
Doug Harrison
Visual C++ MVP
Oct 17 '06 #2
Thanks. That raises a question I've long wondered about: What is the
actual difference between the single-threaded, multi-threaded, and debug
versions of the DLL? The documentation is very vague on this issue. My
guess is that the non-debug versions of the DLL are compiled with
optimizations enabled, thus making it more difficult to step through the
included library source code in a debugger. But what does the
multi-threaded DLL get me, and what is the cost?

- Bob

"Doug Harrison [MVP]" <ds*@mvps.orgwrote in message
news:kf********************************@4ax.com...
On Mon, 16 Oct 2006 12:41:29 -0700, "Bob Altman" <rd*@nospam.nospam>
wrote:
>>In my unmanaged C++ app (VS 2005) I have written a class that inherits
from
exception. I want to export this class from a library DLL, but the
compiler
complains because exception is not itself exported. Any words of wisdom?

You need to compile for the multithreaded DLL (/MD or /MDd).

--
Doug Harrison
Visual C++ MVP

Oct 17 '06 #3
Bob Altman wrote:
Thanks. That raises a question I've long wondered about: What is the
actual difference between the single-threaded, multi-threaded, and debug
versions of the DLL?
Theoretically there can be 8 different versions of the standard library,
as there are 3 completely independent parameters that you could adjust:

- Threading model. The single-threaded std library doesn't work with
multi-threaded applications. As of VS 2005, there is no longer a single
threaded standard library. Microsoft no longer wants to go through the
trouble of maintaining 8 differnt versions of the C standard library.
When most applications are multi-threaded, and the benefits of a
single-threaded library are marginal.

- Dynamic or static linking. Dynamic linking means that the standard
library is provided as DLLs. Static linking means your application is
self standing and doesn't depend on any non-system DLL (your EXE is all
you need to ship in that case). With .NET, static linking is ruled out.

- Debug or release version. In a VC++ project you can't successfully mix
debug and release units -- you have to compile all your units with
either debugging enabled or disabled uniformly. The standard library has
to match your settings as well. So if you want to be able to debug your
application, you have to link the debug version of the runtime library.

If you program in .NET, you don't have too many choices: Either use the
debug or release build of the multi-threaded DLL version of the standard
library. If you program native, and you really really want a
self-standing executable with no dependencies, link either the debug or
release build of the multi-threaded static version of the standard library.

Unless you really know what you're doing, you should compile every
module of your project with the very same compiler and linker settings.
There are special rules to follow when you intermix modules built with
different settings (or even worse, different compilers).

Most importantly, if you want to write your own DLLs, and you choose to
use the static version of the standard library, then the DLL will have a
different memory manager than your EXE, which is very painful to handle
(and it is not a trivial task to manage). By using the DLL version of
the standard library, you can forget about most of the trouble, as long
as everything is built with the same compiler using the same settings.

Tom
Oct 17 '06 #4

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

Similar topics

0
by: Thomas 'Skip' Hollowell | last post by:
My Struts application is attempting to export the contents of a table to a CSV text file. I have gotten this to work in the past but am now having trouble after the export in getting the...
205
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
1
by: seash | last post by:
class xyz{ public void somefunction{ if(this.folderBrowserDialog1.ShowDialog() == DialogResult.OK) { m_varFolderPath = this.folderBrowserDialog1.SelectedPath; m_varFolderPath += ...
4
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...
3
by: BobAchgill | last post by:
I am trying to read in a xml file that I exported from my MSAccess table using the following lines of code but it bombs. Is this the right code? Is there a way to get a clean export from Access...
3
by: amirbehzadan | last post by:
Hello, I am writing some C++ classes and want to export them as .dll files so other users can import them and use the methods I have provided in those classes. I have two types of classes :...
1
by: davebaranas | last post by:
I am able to serialize this but I get a null exception when I try to deserialize it back Even if I don't make any child classes it throws "Object reference not set to an instance of an object."...
1
by: Bruce | last post by:
I am getting the following exception in the release build of my assembly. {"Attempted to read or write protected memory. This is often an indication that other memory is...
5
by: ttc | last post by:
Hi All, I have a managed class that inherits from an unmanged class. The question is, if the object of the manged class get garbage collected, will the memory be free automatically for me or...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
0
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,...

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.