xUnitRevit Exception thrown when opening a document which has been opened using xru.OpenDoc

Hi All,

Thanks for stopping by.

I recently got this exception “A managed exception was thrown by Revit or by one of its external applications.” when I try to open a document which has been opened using xru.OpenDoc.

The goal of the method I test is to activate one document before closing another. Therefore, in my test, I use xru.OpenDoc to open document A and open document B. Then, I use my method to activate document A and close document B.

However, it does not work like in production environment where the document A can be opened and activated although it is in active state.

Do anyone experience the same issue? Thank you.

1 Like

Hey @ptran, sorry this post didn’t get attention. I think I moved this to the general discussion as it didn’t seem Speckle-related but more generally Revit add-on problems. But I’m looking again. Are you asking about the XUnitrevit library?

1 Like

Hi @jonathon , thank you for your attention. I’ll make a note and post any items related to xUnitRevit in ‘General discussion’ later.
Yes, I am asking about the xUnitRevit library.

If it’s a managed exception, it would be helpful to find its stack trace and see exactly where it throws and what the inner exception says, can you do so?

1 Like

Hi @teocomi

Thank you for reaching out.

The inner exception message is ‘A managed exception was thrown by Revit or by one of its external applications.’ ,
and for stack trace: ‘at Autodesk.Revit.UI.UIApplication.OpenAndActivateDocument(String fileName) in Autodesk.Revit.UI\UIApplication.cs:line 7010’

To reproduce, here are the steps:

  1. In my tests, I open document A using ‘xru.OpenDoc’. It will return me a doc object.
  2. Then, I use Revit Api to active the same document using the doc object above: ‘uiApp.OpenAndActivateDocument(doc .PathName)’
  3. Exception is thrown at step 2.