Adding a COM refernce in class library project for Revit button

Adding a COM refernce in class library project for Revit button

Anonymous
Not applicable
1,043 Views
8 Replies
Message 1 of 9

Adding a COM refernce in class library project for Revit button

Anonymous
Not applicable

 

I was just wondering if there was a way to add a COM reference(32bit) based dll into a Revit class library.  I am able to add the reference, but when the functions get initiated I get the following warning:

 

Retrieving the COM class factory for component with CLSID {831DA20F-FE64-4A33-B24F-25CEE81939DC} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

 

I believe this is because Revit uses x64 platform while COM references use x86 platform.  I tried switching the platform target to All CPUs and still received this error.  If I switch the platform to x86, the Revit button is not recognized.  Has anybody found a workaround to this issue? 

 

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

jeremytammik
Autodesk
Autodesk

This is not really a Revit API question, and hence this is not the best place to discuss.

 

However, I thought that you need a COM Interop module for that kind of access.

 

Can you confirm?

 

You will probably have better luck searching the Internet for something like 'access com from .net':

 

https://duckduckgo.com/?q=access+com+from+.net

 



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

0 Likes
Message 3 of 9

Anonymous
Not applicable

Yea I think I need to use a COM wrapper or something like that.  In general I don't think adding 32 bit dlls into 64 bit applications is good practice.

 

Thanks

0 Likes
Message 4 of 9

corinne.astori
Advocate
Advocate

Hi,

I am having a similar issue. The error doesn't occur on my machine, but on a user's machine. How did you solve the issue?

Thank you

 

Corinne

0 Likes
Message 5 of 9

Anonymous
Not applicable
Accepted solution

this occurs when an addin is using a COM reference but that reference is not registered on the users machine.  If this is not programming related, I would check if the addin you are trying to use has an necessary programs that it is dependent on.

 

 If you have the dll you need, register it on the machine : https://helpdeskgeek.com/how-to/register-dll-file-in-windows/.

 

If you are creating the plugin with a 32 bit dll in mind, I would recommend creating a server (synch or asynch pipes). Have the server call the platform target x86 program that performs the 32 bit operation and return the information back to Revit.

 

0 Likes
Message 6 of 9

corinne.astori
Advocate
Advocate

@Anonymous 

Thanks for your quick response!

Did I get it right? (Sorry I am not a very experienced programmer)

The user should register the Word Interop dll on his machine?

So the problem might well be on the user machine and not in my add-in?! A previous version of the add-in was working perfectly on his machine and the code that is causing the error did not change from previous to current version. Maybe he did something in the meanwhile with MS Office.

Thnak you very much.

Kind regards

Corinne

 

0 Likes
Message 7 of 9

Anonymous
Not applicable

If the addin works on other peoples machines then yes it is user specific. If you had version updates since then (either with the addin or MS Office) I would double check the references match.  IE, the dlls being referenced from MS Office to run the addin match the new version of MS Office your users are using.

 

Id probably start with an uninstall of MS Office and reinstall as this will register the COM dlls automatically to your computer.  If not, you can go the manual route, by registering the COM dll yourself, but this is not common practice and is generally avoided.

0 Likes
Message 8 of 9

corinne.astori
Advocate
Advocate

The add-in is working on my machine and also on other 4 users'machine (test machines). The references to the Word Interop dll in the revit add-in project are updated (last version).

 

Thank you again for your help. I really appreciate!

 

Regards

Corinne

0 Likes
Message 9 of 9

corinne.astori
Advocate
Advocate

@Anonymous 

You were right. The problem was on the user machine. Uninstalled and reinstalled MS Office... now works as expected.

Thank you.

Regards

Corinne

0 Likes