Hello everyone. I have a problem when using WPF in revit api.
I use MVVM pattern. Revit crashes, when an unexpected exception occurs in ICommand. Try/catch in IExternalCommand doesn't help. Tried use AppDomain.CurrentDomain.UnhandledException and AppDomain.CurrentDomain.FirstChanceException.
I also tried using WPF template without MVVM (https://thebuildingcoder.typepad.com/blog/2020/01/revit-wpf-add-ins-and-template.html). I put a "throw new Exception()" in the button click handler. Revit also shuts down.
How can I avoid this problem?
The user can work with large projects. I would hate to lose progress because of an unexpected error.
Can you provide any portion of the code related to the error, the error message details, and a little more description of when / how the error occurs? I don't believe your current description "it isn't working" is really enough for anyone to be able to help you very well.
Do you have instances of Revit elements in your ViewModels which have properties bound to your UI? Revit can (will always?) CTD when a binding attempts to access a Revit element that is no longer valid.
I recall I have given an example of how these works see this post.
let us know what was the error you experienced so we can be able to assist
Can't find what you're looking for? Ask the community or share your knowledge.