Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2007

Tip: Looking for answers? Try searching our database.

exceptions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dragonslayer008@hotmail.com - 17 Sep 2007 02:58 GMT
I read in a C++/CLI book that:

"In C++/CLI, exceptions are always thrown on the managed heap, never
the stack."

So I'm wondering if this will be a problem for me.  Here is my
situation.

I am using C++/CLI mainly to wrap some unmanaged C++ code so the code
can be used from C# via a DLL.  My unmanaged code can throw some
exceptions (unmanaged exception class).

My question is, can the methods of the managed class try and catch the
unmanaged exceptions?  That is, could I write something like this in a
managed class method:

try
{
    native->foo();
}
catch( NativeException e)
{
   ...
}

If not, I guess I need to move the native exception handling down into
the unmanaged classes?
Doug Semler - 17 Sep 2007 03:42 GMT
>I read in a C++/CLI book that:
>
[quoted text clipped - 23 lines]
> If not, I guess I need to move the native exception handling down into
> the unmanaged classes?

AFAIK, all exceptions (both SEH and C++) are wrapped into a "generic"
SEHException class that can be caught in managed code.  I do not know that
you can get the type (or any of the contents) of the unmanaged exception
type that was thrown from the unmanaged code...but I believe there's a way
to get at least the value if it's an SEH exception type.

I'm pretty sure there's a bunch of information in MSDN on SEH exceptions and
how they're handled in managed code...

Signature

Doug Semler, MCPD
a.a. #705, BAAWA.  EAC Guardian of the Horn of the IPU (pbuhh).
The answer is 42; DNRC o-
Gur Hfrarg unf orpbzr fb shyy bs penc gurfr qnlf, abbar rira
erpbtavmrf fvzcyr guvatf yvxr ebg13 nalzber. Fnq, vfa'g vg?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.