Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8768759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:08:54+00:00 2026-06-13T17:08:54+00:00

I have a tricky combination of C#, C++/CLI and native C++ code. In short,

  • 0

I have a tricky combination of C#, C++/CLI and native C++ code. In short, what I have:

  1. A third-party managed application, namely, the Visual Studio 2010 process
  2. A C++/CLI dll which is loaded by this process, namely, an Evaluator Add-In
  3. A C# assembly with a Windows.Froms.Form class in it, which is shown by the dll

I show my C# form from the C++/CLI dll with the ShowDialog method:

System::Reflection::Assembly^ GUI = System::Reflection::Assembly::LoadFrom("MyCppDll.dll");
Type^ FormMain = GUI->GetType("MyCsNamespace.FormMain");
MethodInfo^ ShowDialog = FormMain->GetMethod("ShowDialog", gcnew array<Type^>{});
System::Object^ form = System::Activator::CreateInstance(FormMain, args);
ShowDialog->Invoke(form, nullptr);

All works fine, except I don’t know how to handle exceptions which may be thrown during form execution. I wish the ShowDialog->Invoke call just throws these exceptions, but it ain’t.

I’ve tried to set AppDomain::UnhandledException handler in C++, but it is not triggered. The weird thing, I tried to set it in C#, but it is not triggered either.

So how do I handle exceptions in C++ dll which is thrown in C# assembly in this situation? I have full control over C++ and C# code, but the host application is closed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:08:55+00:00Added an answer on June 13, 2026 at 5:08 pm

    ShowDialog->Invoke will throw a TargetInvocationException; the InnerException of this will be the exception that the form throws.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Unicode Win32 application that uses 3rd party libraries, some of which
I have a bunch of Velocity template files in a Visual Studio 2008 project,
so i have a little tricky combination here Company has many Users User belongs
I have a tricky problem that has had me scratching my head for a
I seem to have a tricky problem since the latest ADT update to release
my first time posting. I have a tricky task of finding the latest date
I have a very tricky problem going on with content inside a textarea on
I have the following tricky problem: I have implemented a (rather complicated) class which
I have sort of a tricky problem I'm attempting to solve. First of all,
I have what I think is a tricky question, but hopefully someone on here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.