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 8541415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:49:35+00:00 2026-06-11T11:49:35+00:00

In my Autocad.NET app I want to log all unhandled exceptions using log4net. AutoCAD

  • 0

In my Autocad.NET app I want to log all unhandled exceptions using log4net. AutoCAD itself shows an error dialog with a detailed message -> so there must be a way to register to a certain event.

I tried to register the AppDomain.CurrentDomain.UnhandledException event at app initialization:

AppDomain.CurrentDomain.UnhandledException += (s, e) =>
{
     System.Exception exception = (System.Exception)e.ExceptionObject;
     log.Error(String.Format("Unhandled Exception: {0}\n{1}", exception.Message, exception.StackTrace));
};

But this event is never fired.

  • 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-11T11:49:37+00:00Added an answer on June 11, 2026 at 11:49 am

    In ObjectARX, there is a function called acedDisableDefaultARXExceptionHandler. You can try to P/Invoke it.

        // EntryPoint may vary across autocad versions
        [DllImport("acad.exe", EntryPoint = "?acedDisableDefaultARXExceptionHandler@@YAXH@Z")]
        public static extern void acedDisableDefaultARXExceptionHandler(int value);
    

    You can also try System.Windows.Forms.Application.ThreadException: http://through-the-interface.typepad.com/through_the_interface/2008/08/catching-except.html

    The simplest way to do this is to wrap all your code in a try/catch block. In AutoCAD, there is 2 ways to execute code :

    With a command

    To avoid duplicate code, declare an interface like this:

    public interface ICommand
    {
      void Execute();
    }
    

    Then use it for your command:

    public class MyCommand : ICommand
    {
      void Execute()
      {
        // Do your stuff here
      }
    }
    

    In the class where your commands are defined, use this generic method to execute :

    void ExecuteCommand<T>() where T : ICommand
    {
      try
      {
        var cmd = Activator.CreateInstance<T>();
        cmd.Execute();
      }
      catch (Exception ex)
      {
        Log(ex);
      }
    }
    

    Now your command looks like this:

    [CommandMethod("MYCMD", CommandFlags.Modal)]
    public void MyCommand()
    {
      ExecuteCommand<MyCommand>();
    }
    

    In an event handler

    In this case, as you need the event arguments, simply wrap your code in the try/catch directly.

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

Sidebar

Related Questions

I'm hosting my .Net ListView control using PalettSet in AutoCAD 2012. The Tag property
I am using AutoCAD 2012 and the .NET API. Can someone help me how
I've re-created the _DAcadApplicationEvents interface from an AutoCAD interop .dll using .NET Reflector, and
I have a file with extension .dwg (AutoCAD), and I want to call that
I am creating a class library for AutoCAD with .NET. The problem is that
How can be autocad file (dwg) converted to jpeg or gif file using java
I'm developing an AutoCad plugin (MFC dll), I'm using Visual Studio 2010 and C++.
I am expoloring currently an AutoCAD .NET API to create a dwg files from
I have a AutoCAD 2008 plugin written in VB.NET. This plugin uses mostly the
I'm creating an AutoCAD viewer using directX, and am trying to implement paperspace/modelspace functionality.

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.