<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Handling the InternalException or an application crash from the add-in. in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/handling-the-internalexception-or-an-application-crash-from-the/m-p/8175140#M48428</link>
    <description>&lt;PRE&gt;AppDomain.CurrentDomain.FirstChanceException += CurrentDomainOnFirstChanceException;

public static void CurrentDomainOnFirstChanceException(object sender, FirstChanceExceptionEventArgs e)&lt;BR /&gt;{&lt;BR /&gt;    if (e.Exception is InternalException) {&lt;BR /&gt;        MessageBox.Show($"{e.Exception.Source}{e.Exception.StackTrace}\n {e.Exception.Message}");&lt;BR /&gt;    }&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;This seems to be doing the job actually, even though it gets fired on every single exception before the application gets the chance to handle it internally. The add-in remains loaded and I can get some information out and post some data to my server. I would love to hear other ideas though!&lt;/P&gt;</description>
    <pubDate>Fri, 03 Aug 2018 06:09:29 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-08-03T06:09:29Z</dc:date>
    <item>
      <title>Handling the InternalException or an application crash from the add-in.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/handling-the-internalexception-or-an-application-crash-from-the/m-p/8175061#M48427</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an add-in that monitors open document elements, read-only, figuring how many sheets, links, families etc., using a bunch of IUpdaters, and further sends them off to an external server for some usage analysis. I would like to be able to detect a crash in the application, before the "Unrecoverable error has occurred" dialog, so I can flag my monitoring data with the last result as "crashed", which would help me with the analysis.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to say that I am simulating a crash by running two FilteredElementCollectors in a BackgroundWorker, I know, blasphemy. This causes an InternalException with the error/submit report dialog.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I've tried so far:&lt;/P&gt;&lt;P&gt;- As per The Building Coder: &lt;A href="http://thebuildingcoder.typepad.com/blog/2013/10/handle-your-own-exceptions-and-edit-slab-boundaries.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2013/10/handle-your-own-exceptions-and-edit-slab-boundaries.html&lt;/A&gt; subscribing to the App.Domain.CurrentDomain.UnhandledException doesn't work for me and the handler doesn't get called.&lt;/P&gt;&lt;P&gt;- FailureProcessor and FailurePreprocessor don't work with the InternalException, perhaps I need a better crashing sample file.&lt;/P&gt;&lt;P&gt;- A watchdog application (wrapper) that calls the Revit executable and looks at the exit code/reads the journal file, this works, but would be better to have a self-contained solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'm trying to achieve:&lt;/P&gt;&lt;P&gt;- Before Revit throws and exists, I collect some bits of info, timestamps (no longer need RevitAPI), and make a POST to a webapi with this info.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;</description>
      <pubDate>Fri, 03 Aug 2018 04:49:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/handling-the-internalexception-or-an-application-crash-from-the/m-p/8175061#M48427</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-03T04:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Handling the InternalException or an application crash from the add-in.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/handling-the-internalexception-or-an-application-crash-from-the/m-p/8175140#M48428</link>
      <description>&lt;PRE&gt;AppDomain.CurrentDomain.FirstChanceException += CurrentDomainOnFirstChanceException;

public static void CurrentDomainOnFirstChanceException(object sender, FirstChanceExceptionEventArgs e)&lt;BR /&gt;{&lt;BR /&gt;    if (e.Exception is InternalException) {&lt;BR /&gt;        MessageBox.Show($"{e.Exception.Source}{e.Exception.StackTrace}\n {e.Exception.Message}");&lt;BR /&gt;    }&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;This seems to be doing the job actually, even though it gets fired on every single exception before the application gets the chance to handle it internally. The add-in remains loaded and I can get some information out and post some data to my server. I would love to hear other ideas though!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Aug 2018 06:09:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/handling-the-internalexception-or-an-application-crash-from-the/m-p/8175140#M48428</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-03T06:09:29Z</dc:date>
    </item>
  </channel>
</rss>

