2

I have created a simple .NET COM-visible DLL 4.7.2 which I successfully exposed to COM via project settings as well as class tags like:

<ComVisible(True), Guid("4420535A-7EDA-4EB1-8CFE-963B527285C5")>
<ProgId("EDMSApiCOMWrapper.EDMSCOMClient")>

and a corresponding tabg on the class interface:

<ComVisible(True), Guid("3309A516-6622-4390-B0E4-C6004DAAFEC4")>
<InterfaceType(ComInterfaceType.InterfaceIsDual)>

I signed it with an .snk file I generated using the .NET tool and targeted x86 for build since I will need to use this app on a Windows 7 32-bit machine with VB6.

It built in VS 2019 no problem and generated the Type Lib (.tlb).

I put a simple public method to add numbers in the one public class.

I moved my build .dll and .tlb to my Win7 32-bit dev machine where I will need to use it in VB6.

I ran:

gacutil /i EDMSApiCOMWrapper.dll

and

regasm /codebase EDMSApiCOMWrapper.dll

and that worked fine.

I then added a reference to my EDMSApiCOMWrapper.tlb in my VB6 project and that worked then I was able to instantiate the class:

Dim myObj As EDMSApiCOMWrapper.EDMSCOMClient
Set myObj = New EDMSApiCOMWrapper.EDMSCOMClient
Dim r As Int
r = myObj.MyAddMethod(5,4)

And r was 9 as expected. Huzzah!

Ok, so that was a simple test to make sure I had the referencing steps down. So now I added some real code to my method, which makes use of other .NET dll's in its imports and uses those classes. Some of the dll's are ones we control, some are third party (no control).

I rebuilt and re-gac's and regasm'd my COM wrapper dll and made sure all the dll's it references are in the same directory with my COM dll.

My COM wrapper only references one library (AlfrescoAPI) which was built by us using .NET standard 2.0, and it has dependencies on several other 3rd party .NET libraries.

When I try to run and call a method now in VB6 I get this error message:

This error message

Now, I made sure that AlfrescoAPI (which we control) was strongly named (signed using an .snk file... perhaps I need to do more on that front?).

So in summary:

I am able to build a COM-visible library in .NET 4.7.2, register it on my Win 7 32-bit machine and reference and call methods in VB6 on it, but when modify my COM visible .NET 4.7.2 to reference another .NET library we built (.NET standard 2.0) and that library references other third party .NET dll's I get the problems above.

I am wondering if this is even possible to go further and if so, what steps must I do to get the referenced dll's to work with my 32-bit VB6 program Win 7 project.

GSerg
  • 76,472
  • 17
  • 159
  • 346
eps
  • 31
  • 1
  • 1
    IIRC if you do not sign your COM visible assembly the requirement for referenced assemblies to also be signed will dissapear. Alternatively you could try https://www.nuget.org/packages/Brutal.Dev.StrongNameSigner/ – Alex K. Mar 24 '22 at 22:10
  • @AlexK. Hmm..I'll try un-signing my original wrapper .NET project, but if I recall, my initial test just referencing that in VB6 didn't work unless it was strongly signed. – eps Mar 25 '22 at 03:26
  • Do you really need strong naming? If you use /CodeBase you don't need the GAC and if you don't need the GAC you don't need strong names. – Simon Mourier Mar 25 '22 at 07:19
  • @SimonMourier Ok...so right now I've been GAC and Regasm my primary COM enabled .net 4.7.2 wrapper class. It is strongly named and the .net standard 2.0 library it references is strongly named, but that library then references a few third party dlls(no source,/can't build) that are not strongly named. I GAC'd my .net standard 2.0 library (the one I'm wrapping) and I GAC'd all of it's dependency 3rd party dlls. Are you saying I should not GAC any of it? and just REGASM them all with /codebase? – eps Mar 25 '22 at 20:15
  • @SimonMourier When I try to Regasm /codebase 2 of my third party dependencies I get "RegAsm : warning RA0000: No types were registered" for one of them(NewtonSoft.Json.dll) and I when I try to RegASM JsonSubTypes.dll I get Regasm: errorRA0000: Could not load file or assembly 'Newtonsoft.Json, Version 10.0.0.0, Culture-neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of it's dependecies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) – eps Mar 25 '22 at 20:21
  • Yes, forget about the GAC completely. Regasm is for .NET COM object so "No types were registered" is normal if the dll contains no COM object, in general, you should not regasm a dll you don't own. The other error is not specific to regasm, it just means this JsonSubTypes dll has a reference issue: https://stackoverflow.com/questions/215026/the-located-assemblys-manifest-definition-does-not-match-the-assembly-reference but are you sure you must regasm this one? does it contain a COM object? – Simon Mourier Mar 26 '22 at 05:47

0 Answers0