I'm a new one in the development of the Revit addins. And I have one problem. Currently, Revit 2023 doesn't load my custom C# addin.
So, I have only one DLL file, that called MyTestAddin.dll. It's placed in the D:\WorkingProjects\MyTestAddin\x64\Debug\MyTestAddin.dll path.
It has the next class:
namespace MyTestNamespace
{
public class MyTestAddin : IExternalApplication
{
public MyTestAddin()
{
}
public Result OnStartup(UIControlledApplication application)
{
return Result.Succeeded;
}
public Result OnShutdown(UIControlledApplication application)
{
return Result.Succeeded;
}
}
}
And I create a MyAddin.addin file and place it in the C:\ProgramData\Autodesk\Revit\Addins\2023 folder. Here is the code of my manifest file:
<?xml version='1.0' encoding='utf-8'?>
<RevitAddIns>
<AddIn Type="Application">
<Name>My Addin</Name>
<Assembly>D:\WorkingProjects\MyTestAddin\x64\Debug\MyTestAddin.dll</Assembly>
<ClientId>D784D34F-774E-4707-A313-B1C999A18544</ClientId>
<FullClassName>MyTestNamespace.MyTestAddin</FullClassName>
<VendorId>SomeVendor</VendorId>
<VendorDescription>Some Description about Vendor</VendorDescription>
</AddIn>
</RevitAddIns>
All looks as in the Revit guide. Assembly tag has a full path to the my DLL, FullClassName tag has a full class name including the namespace.
I added the full path to the Revit to the "Start external program" in the "Debug" option of the project. And I created a breakpoints inside the constructor and methods. But when I run my Revit from the Visual Studio, it doesn't catch any breakpoints. So it's looks like my addin isn't loaded to the Revit.
So I added some test code from some random guide that should create a new tab with a new panel and buttons:
// Create a custom ribbon tab
string tabName = "This Tab Name";
application.CreateRibbonTab(tabName);
// Create two push buttons
PushButtonData button1 = new PushButtonData("Button1", "My Button #1", "SomePath", "SomeCommand");
PushButtonData button2 = new PushButtonData("Button2", "My Button #2", "SomePath", "SomeCommand");
// Create a ribbon panel
RibbonPanel m_projectPanel = application.CreateRibbonPanel(tabName, "This Panel Name");
// Add the buttons to the panel
List<RibbonItem> projectButtons = new List<RibbonItem>();
projectButtons.AddRange(m_projectPanel.AddStackedItems(button1, button2));
But in this case I still don't see any new tab and panel in the Revit. And it still doesn't catch any breakpoints.
What is my problem? What's wrong?
Your external application implementation MyTestAddin
is perfectly sufficient for the test. No further code is required or useful. The breakpoint in OnStartup
should be hit when loading. The only remaining requirement is to specify the full add-in path in the Assembly
tag in the add-in manifest, which you seem to be doing, and to place the add-in manifest in the Revit AddIns
folder. For full details, check the Revit API Developers Guide sections on Add-In Integration and Add-in Registration.