Error loading tool into API

Error loading tool into API

Anonymous
Not applicable
310 Views
2 Replies
Message 1 of 3

Error loading tool into API

Anonymous
Not applicable
hi everyone, my name is Drew and I am just starting to learn vb.net to get this Revit API working for me. just wanted to say hi as its my first post in this group!!!

I have tried to make a "hello world" command however I get a message regarding System.TypeLoad.Exception (attached) when running from revit mep 2010.

I created the dll using Visual Studio 2008 Professional and it all loads into revit so I think I got the revit.ini correct.

my code is:

Imports Autodesk.Revit

Public Class Message
Implements IExternalCommand

Public Function Execute(ByVal commandData As Autodesk.Revit.ExternalCommandData, ByRef message As String, ByVal elements As Autodesk.Revit.ElementSet) As Autodesk.Revit.IExternalCommand.Result Implements Autodesk.Revit.IExternalCommand.Execute

MsgBox("Hello World")
Return IExternalCommand.Result.Succeeded

End Function
End Class

I have added the RevitAPI.dll as a reference

I have set the start action to the revit.exe file

Can anyone let me know which setting I am missing or point me in the right direction please?

Thanks

Drew J
North Vancouver
0 Likes
311 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
It looks like the class name in your Revit.ini file may not be fully-qualified.

In your Revit.ini file, you have to include the fully-qualified name of the class, *including the namespace* prefix for the class name. Example:

[ExternalCommands]
ECCount = 1

ECName1 = Message
ECClassName1 = HelloWorld.Message
ECAssembly1 = D:\Revit API\Hello World\Output\HelloWorld.dll
ECDescription1 = Hello World Message


In this example, for ECClassName1 the name space in your project would be HelloWorld and the class name would be Message. Substitute for whatever your name space and class name are (though the above is probably correct).
0 Likes
Message 3 of 3

Anonymous
Not applicable
sorry i see no errors in your code, following is regarding the error from microsoft:
http://msdn.microsoft.com/en-us/library/ms241883.aspx

also, in the "sample" folder in the SDK, two samples have similar VB.net code, maybe you want to check. they are "HelloWorld" and "HelloRevit"

ps, i think you might think about using c# instead of vb.net? it's not that difficult and it's the native language for .net.

good luck!
0 Likes