Custom add-in using C# Debugg & External Application Error

Custom add-in using C# Debugg & External Application Error

Nathan.HilsonN67V6
Advocate Advocate
1,855 Views
8 Replies
Message 1 of 9

Custom add-in using C# Debugg & External Application Error

Nathan.HilsonN67V6
Advocate
Advocate

I'm just getting started with C# with visual studios and having issues getting the application to run. The command loads in fine on its own under the add-ins but if I try and put it under a panel I get a bunch of errors. I get two errors. First is the dubug: 

 

NathanHilsonN67V6_0-1642426148251.png

 

Second is external tool failure: 

NathanHilsonN67V6_1-1642426229120.png

Local Copy is set to False.

 

Below is the code I'm using for the App.cs

 

 

 

 

#region Namespaces
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;
using System.Collections.Generic;

#endregion

using System.Diagnostics;
using System.Windows.Media.Imaging;
using System.Reflection;


namespace TpMechanical
{
internal class App : IExternalApplication
{
public Result OnStartup(UIControlledApplication a)
{
//Note: Option 1.


String tabname = "TpMechanical";
String panelname = "Tools";

//Creating The Tab
a.CreateRibbonTab(tabname);
//Note:Tab Panel.
var Toolspanel = a.CreateRibbonPanel("tabname", "panelname");
//Note: creating The Buttons.
var button1 = new PushButtonData("TpMechanical button1", "Button 1", Assembly.GetExecutingAssembly().Location, "TpMechanical.Command");
button1.ToolTip = "Custom Set of TpMechanical Tools";
button1.LongDescription = "TpMechanical Tools are copyrited by TpMechanical";
var btn1 = Toolspanel.AddItem(button1) as PushButton;

//Note: Stacked Buttons.
var button2 = new PushButtonData("TpMechanical button2", "Button 2", Assembly.GetExecutingAssembly().Location, "TpMechanical.Command");
button2.ToolTip = "Custom Set of TpMechanical Tools";
button2.LongDescription = "TpMechanical Tools are copyrited by TpMechanical.";


var button3 = new PushButtonData("TpMechanical button3", "Button 3", Assembly.GetExecutingAssembly().Location, "TpMechanical.Command");
button3.ToolTip = "Custom Set of TpMechanical Tools";
button3.LongDescription = ("TpMechanical Tools are copyrited by TpMechanical, \n" +
"NO use of tools outside of the organization has been deemeed illegal & in violation of employment contract");

Toolspanel.AddStackedItems(button1 , button2, button3);

//Note: Option 2.
//RibbonPanel curPanel = a.CreateRibbonPanel("TpMechanical", "Tools");

//string curAssembly = System.Reflection.Assembly.GetExecutingAssembly().Location;
//string curAssemblyPath = System.IO.Path.GetDirectoryName(curAssembly);

//Note: Verify Revitapi, Revitapiui, & Presentationcore are active in References.

//PushButtonData pbd1 = new PushButtonData("All Text to UPPER", "All Text" + "\r" + "to UPPER", curAssembly, "TpMechanical.Command");
//PushButtonData pbd2 = new PushButtonData("All Text to lower", "All Text" + "\r" + "to lower", curAssembly, "TpMechanical.Command");
//PushButtonData pbd3 = new PushButtonData("All Text to UPPER", "All Text" + "\r" + "to UPPER", curAssembly, "TpMechanical.Command");
//PushButtonData pbd4 = new PushButtonData("All Text to lower", "All Text" + "\r" + "to lower", curAssembly, "TpMechanical.Command");

//pbd1.LargeImage = new BitmapImage(new Uri(System.IO.Path.Combine(curAssemblyPath, "1788592.png")));
//pbd2.LargeImage = new BitmapImage(new Uri(System.IO.Path.Combine(curAssemblyPath, "icon_1.png")));
//pbd3.LargeImage = new BitmapImage(new Uri(System.IO.Path.Combine(curAssemblyPath, "icon_1.png")));
//pbd4.LargeImage = new BitmapImage(new Uri(System.IO.Path.Combine(curAssemblyPath, "icon_1.png")));

//PushButton pb1 = (PushButton)curPanel.AddItem(pbd1);
//PushButton pb2 = (PushButton)curPanel.AddItem(pbd2);
//PushButton pb3 = (PushButton)curPanel.AddItem(pbd3);
//PushButton pb4 = (PushButton)curPanel.AddItem(pbd4);

return Result.Succeeded;
}

public Result OnShutdown(UIControlledApplication a)
{
return Result.Succeeded;
}
}

 


}

0 Likes
Accepted solutions (2)
1,856 Views
8 Replies
Replies (8)
Message 2 of 9

Sean_Page
Collaborator
Collaborator
Accepted solution

You are not being consistent with how you are using your Tab and Panel names.

 

Here is your code, and you can see that you use the tabname variable to create the tab, but then use "tabname" text when trying to create the panel on the tab. 

String tabname = "TpMechanical";
String panelname = "Tools";

//Creating The Tab
a.CreateRibbonTab(tabname);
//Note:Tab Panel.
var Toolspanel = a.CreateRibbonPanel("tabname", "panelname");
//Note: creating The Buttons.

 

This should help:

String tabname = "TpMechanical";
String panelname = "Tools";

//Creating The Tab
a.CreateRibbonTab(tabname);
//Note:Tab Panel.
var Toolspanel = a.CreateRibbonPanel(tabname, panelname);
//Note: creating The Buttons.

 

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
Message 3 of 9

Nathan.HilsonN67V6
Advocate
Advocate

@Sean_Page  Ahh I see . Thanks, that solved part of my issue. I'm still having issues with the debugger. 

0 Likes
Message 4 of 9

RPTHOMAS108
Mentor
Mentor

That's a very specific message and if your search for it specifically you'll find a few results pointing to anti-tamper. It is likely you are coming up against a component containing that same thing.

 

Seems odd for VS to tell you there is a debugger running whilst debugging no?

Message 5 of 9

Nathan.HilsonN67V6
Advocate
Advocate

@RPTHOMAS108I've tried making this build a couple times so I double checked my add-ins and roaming add-ins to make sure I didn't have any duplicates but came up with nothing. All of my debug settings are same as the default revit visual studios template. 

NathanHilsonN67V6_1-1642461622174.png

If it's an anti-tamper could it be something with the GUID's?

 

 

0 Likes
Message 6 of 9

RPTHOMAS108
Mentor
Mentor

Probably it is one of the project references. I can't advise on the templates since I'm unfamiliar with them.

 

The dialogue box refers to Agile.Net which is an obfuscator. So it appears that an assembly being executed has been protected by this and is detecting if current process has debugger attached (then interfering with your debug process).

 

Would start by looking through the list of references ignoring anything that is part of the RevitAPI (start with 3rd party items) it may be that you are referencing such things via the wrong route.

0 Likes
Message 7 of 9

sonicer
Collaborator
Collaborator
Accepted solution

also better if you disable all other plugin in Revit and then Run debug.

0 Likes
Message 8 of 9

Nathan.HilsonN67V6
Advocate
Advocate

Yea I think I've tried about every solution I could find and still get the debug error. I've tried the list below. Double checked my references & GUID's still no luck.  

 

debugging - What exactly does Use Managed Compatability Mode disabled - Stack Overflow

 

Solved: cannot start Revit 2015 for API debugging - Autodesk Community - Revit Products

 

Solved: DevTV My First Revit Plugin..Revit.exe' has exited with code -529697949 - Autodesk Community...

 

NathanHilsonN67V6_0-1642605229563.png

 

 

I attached my command script, app, & Assembly.  It's the basic hello Revit script that I played with a little. It has to be something small that I'm missing. Think my next step is going to be to scrap it and see if I have the same issues. 

0 Likes
Message 9 of 9

Nathan.HilsonN67V6
Advocate
Advocate

I had to completely uninstall the plugin that was throwing the debug error and it worked. Took me a while to figure out which one it was. 

0 Likes