Speckle Revit 2.0 conflicts with other plug-in

Hey There! :wave:

I started developing a plug-in for Revit which interacts with Speckle and inspired it for a large part on the technology which was used by the specklesharp / DesktopUI project (Stylet / material design WPF and a separate .exe). Now I am facing problems with starting up my application after I’ve started the Speckle Revit 2.0 plug-in. I think this has to do with the Application.Current which is not empty when starting up my own plug-in, because the Speckle Revit 2.0 close event is canceled and hidden instead of a real close.

Below you see a snippet of the app in debug mode, as you can see the application.current is Speckle.DesktopUI.App, but it should have been something like DataFusr.Revit.Mapping.App.


I am wondering if there is a fix for this on my side, or if it can be fixed on your side?

Cheers,

Dirk

Hey Dirk!

It looks like you’re running an old version of the Revit Connector and the Desktop UI as this screenshot is not how the current versions are launching the UI. If you could pull from main and try this again, it should (fingers crossed!! :sweat_smile:) at least work as expected when launching your application first.

For context, the changes made to this launching mechanism were due to a clash with RhinoInside which also populates Application.Current. This meant that anyone who had RhinoInside installed wasn’t able to launch the Speckle Connector!

The root issue here though is that there can only be one Application.Current in a given app domain. If you want to be running your WPF application in the current app domain alongside other applications (like the Speckle Connector or Rhino Inside), you’ll need to find a way to launch your UI without relying on Application.Current.

Cheers,
Izzy

4 Likes

Thanks for the quick reply! I’ll have a look tomorrow :crossed_fingers:.

Hi Izzy,

Studied the code this morning and tried to implement the way to start up and adding my own app to the “already running” Application.Current app when I start it after I’ve started the Speckle Revit Connector.

But it still seems to be impossible to start my application after the Speckle Revit Connector. When I close Revit, and open my application before Speckle Revit Connector, it opens as it should, but when I try to start the Speckle Revit Connector after there is a fatal crash.

When launching the app it has difficulties to link the ViewModel and the View for the first View(Model). It seems like the IoC container is empty in the ViewManager.

Just a heads up on the current situation, if you have any ideas or a previous experience which can help us please let us know.

Cheers,

Dirk

Hey Dirk!

Glad it’s working as expected when launching before the Revit Connector.

As I said in my initial reply, there can only be one Application.Current in a given app domain. The first WPF app to run is the one that populates it. Again, if you want to be running your WPF application in the current app domain alongside other applications (like the Speckle Connector or Rhino Inside), you’ll need to adjust your code and find a way to launch your UI without relying on Application.Current (which is what the Revit Connector does when Application.Current already exists). You shouldn’t really modify the Application.Current if one already exists as that will mess with whatever application created it. I will admit it’s a pretty niche and tricky situation and was quite difficult to get the Speckle Connector working alongside Rhino Inside.

Cheers,
Izzy

3 Likes

Hey Izzy,

I’ll take that last sentence as a warning :open_mouth: , we’ll choose another route for our plug-in then. Thanks again!

Cheers,
Dirk

1 Like

No problems!

Yes, this issue gave me a lot of headaches for the better part of a week (and we almost gave up) :sweat:
If you can find a different path for this, it will probably be for the best!

Good luck with your development :sparkles: