I've been following Yongan Fu's "Learning MicroStation Addins Step by Step" instructions for creating a MS Addin. Got the C# version running with no problems.
Also trying to do it in VB .NET but am having trouble with the commands being validated by UstnXOM Validate addin utility. Everything appears to be correct but it can not find the functions defined in the command xml file.
Here is my main vb code:
Imports System.Windows.FormsNamespace vbAddins <Bentley.MicroStation.AddInAttribute(KeyinTree:="vbAddins.commands.xml", MdlTaskId:="VBADDINS")> _ Friend NotInheritable Class MyAddin Inherits Bentley.MicroStation.AddIn Private Sub New(mdlDesc As System.IntPtr) MyBase.New(mdlDesc) End Sub Protected Overrides Function Run(commandLine As String()) As Integer MsgBox("VB GO") Return 0 End Function End ClassEnd Namespace
Here is the code for the command:
Imports Bentley.MicroStation.InteropServicesImports Bentley.Interop.MicroStationDGNNamespace vbAddins Class CreateElement Public Shared Sub PopUpMessage() MsgBox("Inside Command") End Sub End ClassEnd Namespace
Here's my xml file: (named: commands.xml)
<?xml version="1.0" encoding="utf-8" ?><KeyinTree xmlns="http://www.bentley.com/schemas/1.0/MicroStation/AddIn/KeyinTree.xsd"> <RootKeyinTable ID="root"> <Keyword SubtableRef="CreateElement" CommandClass="MacroCommand" CommandWord="vbAddins" > <Options Required ="true"/> </Keyword> </RootKeyinTable> <SubKeyinTables> <KeyinTable ID="CreateElement"> <Keyword SubtableRef="Commands" CommandWord="CreateElement"> <Options Required ="true"/> </Keyword> </KeyinTable> <KeyinTable ID="Commands"> <Keyword CommandWord="PopUpMessage"> </Keyword> </KeyinTable> </SubKeyinTables> <KeyinHandlers> <KeyinHandler Keyin="vbAddins CreateElement PopUpMessage" Function="vbAddins.CreateElement.PopUpMessage"/> </KeyinHandlers></KeyinTree>
Here's the output from the validator:
Validating VBADDINS AddIn: vbAddins.vbAddins.MyAddin
vbAddins.commands.xml is well-formed and schema valid against KeyinTree.xsd
static method vbAddins.CreateElement.PopUpMessage not found for keyin "vbAddins CreateElement PopUpMessage"
Hi Mike,
Typically I see this when the use default namespace switch is set in the project settings. Recheck that this toggle is off.
HTH,
mark anderson [Bentley]
Visit me at https://communities.bentley.com/communities/other_communities/bentley_innovation/default.aspx
Where would I find this in VB project settings?
It would be the menu item "Project" then to the last item on the menu "Properties" and finally on the Application tab of that page. Then make sure the default namespace is cleared. We updated the wizard at one point to set this correctly.
Answer Verified By: Mike Robertson
Thanks Mark,
Your suggestion got me going in the right direction:
Did 2 things to get it working:
1. Clear the "Root Namespace" entry on the Project\Application tab
2. Deleted "vbAddins" from
<Bentley.MicroStation.AddInAttribute(KeyinTree:="vbAddins.commands.xml", MdlTaskId:="VBADDINS")>
so it became:
<Bentley.MicroStation.AddInAttribute(KeyinTree:="commands.xml", MdlTaskId:="VBADDINS")>
Hello sir Mike,
By using C# version, are you using Visual Studio 2010? Beacuse now I'm using VS 2005 and it doesn't find key-in command.
Best Regards,
Aldrin
Hi Kriller,
Unknown said:Clearing the Root namespace in the application properties fixed this problem for me.
This thread is over 2 years old, so in my opinion if you have the same / similar problem, it would be better to post it as a new question.
BTW Clearing the root namespace in your project may solve the issue, but it is pretty bad solution that breaks rules how NET code should be created. It says that your code is not correct, because any NET addin should use own namespace and MicroStation addins are fully compatible with this approach.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point