Sergey Alikin
Sergey Alikin

Reputation: 161

COM reg free and NET(5,6,7) version: is it possible?

Short description: we have c++ mfc application (client) that uses C# Net Framework 4.6 plugin (server). We also configured regfree between c++ and c# via manifests (at first step) and via embedded manifest (second step, without manifests files into a app folder). All this works perfectly.

And now we are starting to migrate our 4.6 plugin to NET7. Migration is done. All code works correctly. And we can execute it if I register C# plugin via regsvr32 manually. It looks ok.

But when I tried to configure reg free for new NET7 plugin dll, I got an error: 0x8013101b what means "runtime for this dll not found".

We can affect to the runtime version via manifest setting:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity
        name="OnRepoPlugin"
        version="1.0.0.0"
        processorArchitecture="x86">
    </assemblyIdentity>
    <clrClass
        clsid="{25EC9546-7625-4938-B845-A19B3EE3FF3B}" 
        progid="OnRepoPlugin.PI.COnRepoPlugin"
        threadingModel="Both"
        name="OnRepoPlugin.PI.COnRepoPlugin" 
        runtimeVersion="v4.0.30319">
    </clrClass>
    <file
        name="./OnRepoPlugin.comhost.dll"
        hashalg="SHA1">
    </file>
</assembly>

runtimeVersion="v4.0.30319">

There is the description from the Microsoft:

runtimeVersion
Specifies the common language runtime (CLR) version to use. If you do not specify this attribute, and the CLR is not already loaded, the component is loaded with the latest installed CLR prior to CLR version 4. If you specify v1.0.3705, v1.1.4322, or v2.0.50727, the version automatically rolls forward to the latest installed CLR version prior to CLR version 4 (usually v2.0.50727). If another version of the CLR is already loaded and the specified version can be loaded side-by-side in-process, the specified version is loaded; otherwise, the loaded CLR is used. This might cause a load failure.

But as I see from the Microsoft doc page it's applicable only to NET Frameworks version (1, 2, 4). I tried to set it to "v7.0.0" but without luck: the same error (0x8013101b).

So has anybody experience with this couple: NETx + com regfree?

Thanks in any advice.

Upvotes: 1

Views: 552

Answers (1)

Sergey Alikin
Sergey Alikin

Reputation: 161

I don't know how to accept @SimonMourier, so I will paste it here.

The assembly that you target with .NET Core3->7 is not a managed assembly (even if it's main purpose it to load one), it's the native *.comhost.dll. So you don't want to use clrClass, but comClass instead, something like this :

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
   <assemblyIdentity type="win32" name="NetComLib.X" version="1.0.0.0" />
   <file name="NetComLib.comhost.dll">
      <comClass clsid="{9f35b6f5-2c05-4e7f-93aa-ee087f6e7ab6}" threadingModel="Both" progid="NetComLib.Server" />
   </file>
</assembly>

Upvotes: 1

Related Questions