Simultaneously load multiple versions of the same Revit Addin

Simultaneously load multiple versions of the same Revit Addin

Anonymous
Not applicable
1,646 Views
5 Replies
Message 1 of 6

Simultaneously load multiple versions of the same Revit Addin

Anonymous
Not applicable

Hi everyone !

I was sick of reloading Revit foreach changes in my addins code so I made some kind of "Toolbox addin" which is managing all other addins
The Toolbox have a refresh button and if there is a change in some of the .dll files of an addin :

- It downloads it,

- Put it in the Temp folder with an unique name,

- Hide the previous pushbutton,

- Create a new pushbutton with the new assemblypath.

If the new version has no link with the old version it works. (By no links I mean files coming from other Visual Studio solutions). Unfortunately when I use a new version of the same addin it seems like Revit is uniquely identifying it by I don't know which way. Because when I click the new created pushbutton : Revit load the old version with no consideration for the assemblypath I gave him.
Here is a sample of the "ToolBox addin" :

	if (updateOnTheFly)
    {
        foreach (RibbonItem rItem in appItems)
        {
            rItem.Enabled = false; //i hide all other old version
            rItem.Visible = false;
        }
        string tempPath = Path.GetTempPath();
        tempPath = Path.Combine(tempPath, "SYA_TEMP");
        if (!Directory.Exists(tempPath))
        {
			Directory.CreateDirectory(tempPath);
        }

        getNewAssembly(tempPath, server); //i get the new dll and decompress it in the temp folder

        string oldFile = Path.Combine(tempPath, meta.dllName);
        string tempDllChecksum = calculateChecksum(oldFile); //i compute the hash of the new dll to make his name unique
        string newName = tempDllChecksum + ".dll";
        string newFile = Path.Combine(tempPath, newName);

        if (!File.Exists(newFile))
        {
            File.Move(oldFile, newFile); //i rename the new file
            PushButtonData buttonData = new PushButtonData(name + tempDllChecksum, meta.text + "\nnew", newFile, meta.startClassName); //HERE if the "newFile".dll come from the same VS project revit takes the old version for no apparent reason
            buttonData.ToolTip = meta.tooltip;

            BitmapImage bi = ConnectOptionsData.base64ToImage(meta.base64Logo);
            PushButton pushButton = mainPanel.panel.AddItem(buttonData) as PushButton; 
            pushButton.LargeImage = bi;
            pushButton.Image = bi;
        }
	}

If you have already experienced this problem please help !

Thanks anyway !

PS : I know the "attach to process" function of VS but I can't use it because the new .dll is on a distant server !

0 Likes
1,647 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

Various solutions for edit and continue have been discussed by The Building Coder:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.49

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi Jeremy,

I know your blog pretty well and I have read most of your articles,

As I said I cannot use the Attach to Process function of VS.

And I'm not looking for a solution for debug only but also update on non-developers computers.

So if you find out how Revit uniquely identify an addin, please let me know !

Thanks !

0 Likes
Message 4 of 6

stever66
Advisor
Advisor

I believe revit loads the dll files when revit is launched.   Just overwriting the dll file won't change what revit already has in memory.  

 

Addins are are identified by the GUID number assigned in the addin manifest file.  

 

I dont think it is possible to reload to reload the dll without restarting revit, or without using whatever tricks the addin manager uses.

0 Likes
Message 5 of 6

Anonymous
Not applicable

I'm loading addins with my Toolbox that only use one .addin (the one of Toolbox). As Revit autorizes an addin to add addins I think the GUID of the addin file is not the way Revit Identify a loaded .dll.
I'm using this method to add new dlls versions :

PushButtonData buttonData = new PushButtonData(name, meta.text + "\n" + version, path + "/" + meta.dllName, meta.startClassName)
{
    ToolTip = meta.tooltip
};

Then I add the pushbutton to my ribbonPanel.

0 Likes
Message 6 of 6

matthew_taylor
Advisor
Advisor

Hi,

Did you see these posts of Jeremy's?:

http://thebuildingcoder.typepad.com/blog/2013/05/reloading-and-debugging-external-commands-on-the-fl...

http://thebuildingcoder.typepad.com/blog/2013/05/load-your-own-external-command-on-the-fly.html

I figure as long as you're not wanting to replace the application/assembly that has the ribbon items in it, you should be able to use a modification of this approach.

The ribbon commands would just be stubs that load the byte stream each time they're used.

[edit]

Of course, you'd need two assemblies - not just the one you have now.

[/edit]


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes