While updating my employer's Revit 2010 utilities to 2011, I've stumbled upon some interesting behavior with the new add-in manifest files. I've discovered that if I do not include a file path in the
Prior to discovering this, I was using a separate 'DEBUG' manifest file pointing to my debug directory for the Visual Studio 2008 project and a separate 'PRODUCTION DISTRIBUTION' manifest file that pathed to the normal 'addin' directory for my tools to load into Revit 2011.
In order for this example to work, the add-in manifest file still needs to be located in the normal 'Addin' directory in order to load into Revit, but if I start my application from Visual Studio 2008 in debug mode, I have full access to my [target.DLL] even though my [target.DLL] is not loaded in the same directory as the default add-in directory. This may sound confusing, but actually works quite well in that it suites dual purpose:
When I fire up Revit, the DLL saved in the add-in directory is loaded into Revit. When I start Revit from Visual Studio to debug an application, the DLL in my Visual Studio debug directory is loaded into the Revit session.
Here's how I do it for a sample application that loads external DLL command files (the command files must be present in the same directory as the main application DLL being debugged for this example to work):
Imports Autodesk.Revit.UI Imports Autodesk.Revit.Attributes Imports System.Windows.Media.Imaging Imports System.Reflection ''' <summary> ''' Main Ribbon Creation ''' </summary> <Transaction(TransactionMode.Automatic)> _ <Regeneration(RegenerationOption.Manual)> _ Public Class AppExample Implements IExternalApplication Public Sub AddRibbonPanel(ByVal a As UIControlledApplication) ' This 'myPath' variable is the trick to getting the dual debug/execution behavior!!!!!!! Dim myPath As String = Assembly.GetExecutingAssembly.Location.Substring( _ 0, (Assembly.GetExecutingAssembly.Location.LastIndexOf("\") + 1)) Dim rvtPanel As RibbonPanel = a.CreateRibbonPanel("RevitNet Customizations") ' DatabaseLink ; example dll - notice the variable path to the DLL????????????? 'myPath' Dim pbdDatabaseLink As New PushButtonData("Database Link", _ "Database" & vbCr & "Link", _ myPath & "RevitNet.DatabaseLink.dll", _ "RevitNet.DatabaseLink.cmdDatabaseLink") pbdDatabaseLink.Image = New BitmapImage(New Uri(myPath & "RevitNet.DatabaseLink_16.jpg")) pbdDatabaseLink.LargeImage = New BitmapImage(New Uri(myPath & "RevitNet.DatabaseLink_32.jpg")) pbdDatabaseLink.ToolTip = "Bidirectional Link to a Database" & vbCr & "From Revit 2011" ' Add the pushbutton to the ribbon panel Dim myButtonDBL As PushButton = rvtPanel.AddItem(pbdDatabaseLink) End Sub Public Function OnStartup(ByVal a As UIControlledApplication) _ As Result Implements IExternalApplication.OnStartup Try AddRibbonPanel(a) Return Result.Succeeded Catch ex As Exception Return Result.Failed End Try End Function Public Function OnShutdown(ByVal a As UIControlledApplication) _ As Result Implements IExternalApplication.OnShutdown Return Result.Succeeded End Function End Class
'*************************** ; end of VB.NET
The sample manifest file would look like:
<?xml version="1.0" encoding="utf-8" standalone="no"?> <RevitAddIns> <AddIn Type="Application"> <Name>RevitNet Utilities</Name> <Assembly>RevitNet.AppExample.dll</Assembly> <AddInId>2c372fa8-86c5-49f6-ae7b-fcc18481c841</AddInId> <FullClassName>RevitNet.AppExample</FullClassName> </AddIn> </RevitAddIns>
'*************************** ; end of XML Manifest File
Notice there is no file path in the 'Assembly' tag?!?!?!?!