
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I try developing a Revit-addin in Revit 2019 using WPF for the GUI using following minimalized code:
[STAThread]
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
currentDocument = commandData.Application.ActiveUIDocument.Document;
RevitInterface.document = currentDocument;
MessageBox.Show("start application");
var application = new Application();
application.Exit += ApplicationExit;
int returnCode = application.Run(new Window());
MessageBox.Show("application returned with: " + returnCode.ToString());
return Result.Succeeded;
}
private void ApplicationExit(object sender, ExitEventArgs e)
{
MessageBox.Show("exit event");
}
When running this minimal example as an .exe it works fine, but when I try using it from Revit as add-in, it always crashes Revit when exiting. The order of events/outputs is:
- "start application"
- <I close the window by clicking "X" in the top right>
- "exit event"
- <Revit crashes with Popup "Encountered an improper argument">
- "application returned with: 0"
- Afterwards a zombie Revit.exe process remains which needs to be killed before restarting Revit
I already tried the following:
- Removing all add-ins except for my own from C:\ProgramData\Autodesk\Revit\Addins\2019
- Trying it with Revit 2020
- Trying it from another computer
- Closing the application via application.Shutdown() instead of closing the last window
Do you have some ideas how I still can stay the course using WPF for the add-in GUI? I do prefer it over Windows Forms quite a bit.
Solved! Go to Solution.