无法加载OnStartup and OnShutdown这两个函数
提示无法从addin文件中初始化附加模块,因为附加模块注册表中缺少所需名称节点。外部应用程序附加模块需要名称节点。
我设置了addin文件如下
C:\Users\Administrator\Desktop\try\AddPanel\AddPanel\bin\Debug\AddPanel.dll604b1052-f742-4951-8576-c261d1993108Walkthrough.CsAddPanelNAMEYour Company Information
程序如下
using System;
using System.Reflection;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.Windows.Media.Imaging;
namespace Walkthrough
{
///
/// This application's main class. The class must be Public.
///
public class CsAddPanel : IExternalApplication
{
// Both OnStartup and OnShutdown must be implemented as public method
public Result OnStartup(UIControlledApplication application)
{
// Add a new ribbon panel
RibbonPanel ribbonPanel = application.CreateRibbonPanel("NewRibbonPanel");
// Create a push button to trigger a command add it to the ribbon panel.
string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;
PushButtonData buttonData = new PushButtonData("cmdHelloWorld",
"Hello World", thisAssemblyPath, "Walkthrough.HelloWorld");
PushButton pushButton = ribbonPanel.AddItem(buttonData) as PushButton;
// Optionally, other properties may be assigned to the button
// a) tool-tip
pushButton.ToolTip = "Say hello to the entire world.";
// b) large bitmap
Uri uriImage = new Uri(@"c:\ButtonIcon.png");
BitmapImage largeImage = new BitmapImage(uriImage);
pushButton.LargeImage = largeImage;
return Result.Succeeded;
}
public Result OnShutdown(UIControlledApplication application)
{
// nothing to clean up in this simple case
return Result.Succeeded;
}
}
///
/// The "HelloWorld" external command. The class must be Public.
///
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class HelloWorld : IExternalCommand
{
// The main Execute method (inherited from IExternalCommand) must be public
public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit,
ref string message, ElementSet elements)
{
TaskDialog.Show("Revit", "Hello World");
return Autodesk.Revit.UI.Result.Succeeded;
}
}
}
求版主帮住啊,不要留个感谢分享就不管我了