Registering .NET COM Assembly in VBA

Registering .NET COM Assembly in VBA

Anonymous
Not applicable
492 Views
2 Replies
Message 1 of 3

Registering .NET COM Assembly in VBA

Anonymous
Not applicable

I have a .NET assembly I use for common functionality in various applications.  I have created COM objects for several of the functions so that the assembly can be registered in VBA code.  This works perfect fine in Microsoft Access 2007 - I am able to register the TLB file and utilize the functions.  However, I am not able to get the file to register in Inventor VBA.

One notable difference is that when I register the reference through Microsoft Access, it finds it by browsing the C:\Windows\System32 directory even though the file physically resides in C:\Windows\SysWOW64.  Access knows to look there to obtain assemblies for the appropriate bit architecture.  But Inventor does not find the file when browsing C:\Windows\System32.  If I manually point it to the SysWOW64 path, it fails to register the assembly.  There's no error message, it just simply does not insert it into the list of registered components.

So there are obviously key differences between the VBA environment in Inventor versus the environment in Microsoft Office.  Can somebody point me in the right direction?

0 Likes
Accepted solutions (1)
493 Views
2 Replies
Replies (2)
Message 2 of 3

ekinsb
Alumni
Alumni

I think the problem is that Inventor is 64-bit and is expecting a 64-bit component.  The SysWOW64 directory is for 32-bit applications on a 64-bit machine.  How are you registering the typelib?  I suggest doing a bit of searching online about how to register a typelib for 64-bit and your assembly will need to be built for either 64-bit or "Any CPU".


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

My assembly was already configured for "Any CPU".  The problem was that I was registering the assembly and creating the type library using the 32-bit version of regasm.exe.  This caused the type library file (TLB) to be created in \Windows\SysWOW64 - and thus could be utilized in the 32-bit MS Access environment, but was not usable in the 64-bit Inventor VBA environment.

The resolution was to simply register the assembly twice - once with the 32-bit regasm.exe and once with the 64-bit version.  This creates two separate type library files - a 32-bit one in \Windows\SysWOW64 and a 64-bit one in \Windows\System32.

0 Likes