Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Revit crash issue

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
508 Views, 2 Replies

Revit crash issue

Anonymous
Not applicable

Hello all,

I am getting following message (crash) while opening and closing multiple Revit families.

 

Revit Crash.png

I have gone through the following link related to above error message, but we are unable to narrow it down to the exact problem.

Unrecoverable Error 

 

Below is our code snippet,

Autodesk.Revit.DB.Document doc = globalDoc.Application.OpenDocumentFile(filePath);

try
{
	//Some oeprations to get family types
	//and parameters and store them in xml
}
catch (Exception ex)
{
	logDocument.Message(ex.Message, ex.StackTrace);
}

doc.Close(false);
doc.Dispose();

Seeking advice/help on this issue. TIA.

0 Likes

Revit crash issue

Hello all,

I am getting following message (crash) while opening and closing multiple Revit families.

 

Revit Crash.png

I have gone through the following link related to above error message, but we are unable to narrow it down to the exact problem.

Unrecoverable Error 

 

Below is our code snippet,

Autodesk.Revit.DB.Document doc = globalDoc.Application.OpenDocumentFile(filePath);

try
{
	//Some oeprations to get family types
	//and parameters and store them in xml
}
catch (Exception ex)
{
	logDocument.Message(ex.Message, ex.StackTrace);
}

doc.Close(false);
doc.Dispose();

Seeking advice/help on this issue. TIA.

2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

@Anonymous 

Hey,

 

Every time i have gotten this error, i was able to pinpoint it by debugging.

 

They could be caused by an ungodly number of different things, but typically it is an unhandled exception somewhere.

 

My advice would be to attach a debugger to it and go line by line until it fails. The Output and Immediate windows in VS will help immensely.

 

Since you have a try/catch there, i would move the last two lines up inside the try block.

You should be able to glean more information if you haven't already tried that.

Thanks,

 

Matt

0 Likes

@Anonymous 

Hey,

 

Every time i have gotten this error, i was able to pinpoint it by debugging.

 

They could be caused by an ungodly number of different things, but typically it is an unhandled exception somewhere.

 

My advice would be to attach a debugger to it and go line by line until it fails. The Output and Immediate windows in VS will help immensely.

 

Since you have a try/catch there, i would move the last two lines up inside the try block.

You should be able to glean more information if you haven't already tried that.

Thanks,

 

Matt

Message 3 of 3
jlpgy
in reply to: Anonymous

jlpgy
Advocate
Advocate

Hi:

Suppose that you try...catch block is inside an External Command class, isn't it?

Do you use any modeless window? Like winform.Show() or wpfWindow.Show() ?

Those try...catch... can never catch any exceptions that is caused during a modeless window lift cycle.

 

You should also pay attention to those window event handler, such as ......_Click(sender, e), ..._KeyUp(sender, e), etc.

 

As far as the experience of our team, there are 3 main points to which you must pay attention to the protential exceptions:

  1. Inside IExternalCommand.Execute() method, or inside IExternalApplication.OnStartUp() method
  2. Inside Idling event handler, or IExternalEventHandler.Execute() method
  3. In your modeless window event handlers, such as Clicked, KeyUp, Loaded, etc.

Mostly our addin crashes from modeless window handlers.

And, the above mentioned are all based on our EXPERIENCE. 🙂

 

Besides:

Have you noticed the following infomation from Revit API Help Document

Remarks
The currently active document may not be closed by this function. It can only be closed via Revit's UI.
 
The last opened document cannot be closed programmatically.
单身狗;代码狗;健身狗;jolinpiggy@hotmail.com
0 Likes

Hi:

Suppose that you try...catch block is inside an External Command class, isn't it?

Do you use any modeless window? Like winform.Show() or wpfWindow.Show() ?

Those try...catch... can never catch any exceptions that is caused during a modeless window lift cycle.

 

You should also pay attention to those window event handler, such as ......_Click(sender, e), ..._KeyUp(sender, e), etc.

 

As far as the experience of our team, there are 3 main points to which you must pay attention to the protential exceptions:

  1. Inside IExternalCommand.Execute() method, or inside IExternalApplication.OnStartUp() method
  2. Inside Idling event handler, or IExternalEventHandler.Execute() method
  3. In your modeless window event handlers, such as Clicked, KeyUp, Loaded, etc.

Mostly our addin crashes from modeless window handlers.

And, the above mentioned are all based on our EXPERIENCE. 🙂

 

Besides:

Have you noticed the following infomation from Revit API Help Document

Remarks
The currently active document may not be closed by this function. It can only be closed via Revit's UI.
 
The last opened document cannot be closed programmatically.
单身狗;代码狗;健身狗;jolinpiggy@hotmail.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report