chuongmep / RevitAddInManager

Revit AddinManager update .NET assemblies without restart Revit for developer.
MIT License
275 stars 50 forks source link

Testing debug with a modeless form not working? #30

Closed pierrenavarra closed 1 year ago

pierrenavarra commented 1 year ago

Hi @chuongmep

I've got an other pb with my solution and debugging with AIM. I've got an IExternalCommand wich simply put a TextNote into a view and it works when I run it with the AIM. But, I've got an other IExternalCommand wich call a method coded into IExternalApplication with make a Show of a window form. And, in this case, it does'nt work. Do you know why?

chuongmep commented 1 year ago

@pierrenavarra can show some code demo ?

pierrenavarra commented 1 year ago

Events.zip Hi @chuongmep , here is a sample You can click on tab "events" and click on button to show the modeless Also, if ou do it via the AIM, you'll reproduce the pb (hope so :-))

chuongmep commented 1 year ago

Hmm, AIM just execute command inside Execute this :

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
//do something not startup IExternalApplication 
return Result.Succeeded;
}

Reson error because AIM not startup IExternalApplication, IExternalApplication only load when you define .addin, so thisApp will be null now => not working.

Let do some thing to init class

Application app = new Application();
app.ShowForm(commandData.Application);
return Result.Succeeded;
pierrenavarra commented 1 year ago

Yes!!! It works!! And why when I run the command via AIM it works and just after if I click on the button it make an error? Many thx @chuongmep !!

chuongmep commented 1 year ago

@pierrenavarra let ensure that you have copied enough all library to folder add-in ?

pierrenavarra commented 1 year ago

I've got only one dll

chuongmep commented 1 year ago

it work in my computer https://user-images.githubusercontent.com/31106432/186697741-c40292ea-cb09-4713-a35a-30ad70ef5d8f.mp4

pierrenavarra commented 1 year ago

it works when you click on btn and next on running command via AIM? What XCedd.WPF.AvaonDock.dll is?

chuongmep commented 1 year ago

@pierrenavarra Addinmanager can't load a assembly duplicate because we can't unload assembly before, with define .addin in revit, just have way to unload addin is close revit because revit still is in .NET Framework 4.8. https://stackoverflow.com/questions/6258160/unloading-the-assembly-loaded-with-assembly-loadfrom

pierrenavarra commented 1 year ago

Oh I see and is your link is a solution or not? Anyway, many thx to take time to answer me :-)

chuongmep commented 1 year ago

@pierrenavarra it is bad solution, may be needing Autodesk update Revit support .NET Core or NET6 to develop future unload assembly https://docs.microsoft.com/en-us/dotnet/standard/assembly/unloadability

pierrenavarra commented 1 year ago

Ok, I understand. Anyway, AIM works and permits me to debug trace my code and it's cool! Many thx!

chuongmep commented 1 year ago

Thanks for compliment, let contribute if you have any idea 👏

pierrenavarra commented 1 year ago

Hi @chuongmep I still have a pb . Because I'm raising a DocumentClosing event on IExternalApplication...

pierrenavarra commented 1 year ago

Ok, I finded and call my Event on IExternalCommand..Sorry for disturbing