Class cannot be found in the addin assembly VB .net

Class cannot be found in the addin assembly VB .net

rita.aguiar
Advocate Advocate
4,512 Views
13 Replies
Message 1 of 14

Class cannot be found in the addin assembly VB .net

rita.aguiar
Advocate
Advocate

I just started creating a simple add-in application in VB .net for Revit 2019 by following the tutorial:
https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/CloudHelp/cloudhelp/2014/EN... (from Apr 18 2014).

I have completed all steps successfully, however, when clicking on the button to execute my add-in, this message appears:

 

Failed to initialize the add-in "HelloWorld" because the class "HelloWorld" cannot be found in the add-in assembly.
The FullCassName provides the entry point for Revit to call the add.in application. For Revit to run the add-in, you must ensure this class implements the "Atuodesk. Revit.UI.IExternalCommand" interface.

 

I have checked the .dll's properties and it has not been flagged by windows. I am sure the IExternalCommand is implemented. I have tried with a namespace, without a namespace, with a different class name, with the .dll in the same folder as the addin, and tried doing the tutorial again from scratch without renaming the .vb file. Unfortunately it still did not work: it keeps on showing this message, no matter what class name I write.


I have attached some printscreens of the project and the manifest file.


I think the problem is that it is not finding the class in the assembly because the message is tittled "Wrong Full Class Name". so I must have written this wrong in the manifest file. What should I write them?


Many Thanks.

0 Likes
Accepted solutions (1)
4,513 Views
13 Replies
Replies (13)
Message 2 of 14

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @rita.aguiar,

 

In your addin manifest file, 

<Assembly>HelloWorld.dll</Assembly>

This won't work because Revit won't be able to find out the HelloWorld.dll file.

 

The correct way to mention the full path of your .dll file is as shown below

For example

<Assembly>D:\Sample\HelloWorld\bin\Debug\HelloWorld.dll</Assembly>


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 14

rita.aguiar
Advocate
Advocate

Thank you for your help. I have tried with the full path before, but its not the issue (see attached png, also i just changed the namespace in the project and in the addin again to see if it could work with another name). It is recognizing the .dll file and where it is located. According to the message displayed I think I might be getting the Full Class Name wrong, and so it is not finding the Class in the assembly, but I don't know what I should write there then. Can you help me?

0 Likes
Message 4 of 14

jeremytammik
Autodesk
Autodesk

The third message that you attached, .dll loaded, external tools, wrong full class name.png, indicates that Revit is in the process of loading the DLL and requires user confirmation whether this is intentional. You need to confirm that message before your add-in can be loaded.

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 14

rita.aguiar
Advocate
Advocate

Thank you @jeremytammik, I always load the .dll before executing the HelloWorld button. I think the issue is in the FullClassName. Can you help me find what should be the FullClassName?

0 Likes
Message 6 of 14

jeremytammik
Autodesk
Autodesk
Message 7 of 14

stever66
Advisor
Advisor

I'm not sure why you have a namespace of HelloWorld.My.

 

Namespaces are normally just one word, like HelloWorld.   Then your full class name would just be:

 

<FullClassName>HelloWorld.Class1</FullClassName>

 

I was just looking back at your other post.  You did set Copy Local on the RevitAPI and APIUI references to false, correct?  I'm not sure what would happen if those were left set to true.

0 Likes
Message 8 of 14

stever66
Advisor
Advisor

I believe that does work as long as both the .addin file and the .dll file are placed in the same addins folder.

 

This would also work:

 

 

<Assembly>./HelloWorld.dll</Assembly>

 

Either way gives less chance for a typo that putting in the entire path name.

 

 

 

0 Likes
Message 9 of 14

stever66
Advisor
Advisor
Accepted solution

I'm not a visual basic person, but I just ran through the tutorial.  I got it to work, but it took about 5 times because I made a typo in file name when I started the project.  The only changes I made were:

 

1.  Use .Net 4.7 for revit 2019.

2. Change the path in the manifest file to Revit 2019.

3.  When saving the manifest file, change from .txt files to "*.* all files".  This keeps notepad from placing an extra .txt on the end of the filename.

 

Apparently, Visual basic is a little different than C#.  It includes a default namespace even when you don't see it in the code like I am used to seeing for C#.   If you go to "Project", "HelloWorld Properties", you should see a "root namespace" of HelloWorld.   Therefore, the tutorial does have the proper class name in the addin manifest file which is :

<FullClassName>HelloWorld.HelloWorld</FullClassName>

 

Make sure you aren't getting any errors when you build the dll file. 

 

My only other suggestion is to make sure Visual Studio is set to "Debug" in the toolbar.  If it is set to "Release", it will put the .dll file in a different file.  (Its not a bad idea to check the date on the .dll file just to make sure you are using the one that was just made.)

 

Oh, and I couldn't get the line continuation  _ to work, so I had to put the public class on the same line as the Autodesk.Revit.Attributes.... line.  See the attachment below.

 

0 Likes
Message 10 of 14

jeremytammik
Autodesk
Autodesk

Very many thanks to @stever66 for researching this in such depth for you!

 

By the way, VB as a language is rather obsolete, which is one of the reasons why you are running into these kind of issues.

 

VB.NET is kind of self-contradictory, trying to integrate modern object-oriented .NET philosophy with rather outdated VB traditional stuff, cf. 

 

https://www.quora.com/Is-Visual-Basic-NET-a-language-worth-learning

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 11 of 14

rita.aguiar
Advocate
Advocate

Thank you so so much @stever66. The issue was in fact not knowing about the Root Namespace and therefore not mentioning it in the FullClassName of the manisfest file.

0 Likes
Message 12 of 14

rita.aguiar
Advocate
Advocate

@jeremytammik I guess that's the reason why probably I don't see that many posts about the use of VB to create Revit plugins, only C#. I started working with VB .net 2 weeks ago, first created a plugin for AutoCAD and CIVIL 3D and now I have to do the same for Revit. I agree, VB is very complicated!

0 Likes
Message 13 of 14

jeremytammik
Autodesk
Autodesk

Yup, that would be the reason.

 

I would recommend looking at C# or Python instead. They are both fine.

 

Good luck and have fun!

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 14 of 14

abdelrahmanarch1
Observer
Observer

Hello,

I had the same problem and it was solved when I checked all marked places in the attached PNG are the same name with the manifest file and the full class name in the addin file is 
"theclassname.theclassname"
in your case 
"HelloWorld.HelloWorld"