Failed to load my project dll when using modeless dialog
Hello!
When using a modeless wpf dialog with AsyncEventHandler my own project's dll isn't loaded when I need it in an Action given as parameter to AsyncEventHandler. The RaiseAsync() fails then. When I call a method of this dll before showing the dialog, the dll is loaded correctly.
How can I ensure, that my project's dll is loaded correctly without having to call a method of this dll before showing the modeless dialog?
Thanks in advance!
Hi, please provide a code example
https://github.com/jopi177/SampleLoadDllToModelessWPFDialog
Use ExternalCommand instead of IExternalCommand. ExternalCommand ships with a dependency resolver and IExternalCommand without, so your plugin didn't recognize where it could get dependencies
I've already used it...
Which option doesn't work? If you use the Show method, WPF creates a window in another thread and completes the ExternalCommand accordingly. You need to create ViewModel and ExternalEvent before calling Show. For example as here https://github.com/Nice3point/RevitTemplates/blob/develop/samples/SingleProjectWpfModelessApplication/RevitAddIn/ViewModels/RevitAddinViewModel.cs Create a readonly field
Hi, thank you for answering so fast:)
I already do it as you recommend, create ViewModel and ExternalEvent before calling show. The difference to your sample project is, that I want to call code from the modeless dialog which is not in the same project, but in my Core.dll. This .dll can then not be loaded and I don't reach the CallTestMethod() which I want to raise in the asyncEventHandler. If I call any method of this Core.dll before Showing the dialog everything works fine (see comments in code), but this would be a very messy workaround.
Than try to wrap your code CallTestMethod() with ResolveHelper.BeginAssemblyResolve https://github.com/Nice3point/RevitToolkit#resolvehelper
Revit often fails to load third-party libraries, and when using the Show method instead of ShowDialog, the Toolkit scope ends when you exit ExternalCommand. ResolveHelper can help