.NET Client crasch when replacing a COM-registered .dll with a new one in the same .NET version as the client

We have an old C / C ++. Dll registered in COM. Our clients have both their own and .NET clients that use this .dll.

We created a new .NET.dll to replace the old one, i.e. their COM interface is identical. We would like to replace the old .dll without requiring our clients to recompile or take any action to their clients.

For native clients, it works just fine to simply unregister the old .dll and register the new one (with regasm). It also works for some .NET clients. However, in these cases, the client and the new .dll are compiled with the same version of .NET, which makes an exception below.

In other words, this works:

.dll is .NET 3.5 -> client is .NET 4.0 .dll is .NET 4.0 -> client is .NET 3.5 .dll is any .NET -> Client is native 

This produces the action below:

 .dll is .NET 4.0 -> client is .NET 4.0 .dll is .NET 3.5 -> client is .NET 3.5 

[A] BARAPIXLib.barcom5 cannot be added to [B] BARAPIXLib.barcom5.

Type A is taken from "BARAPIXLib, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null" in the context of "LoadFrom" at location C: \ arkiv \ S_BTW \ BTW \ BARAPIXWebService \ Barapix \ bin \ BARAPIXLib.dll.

Type B starts with "BartrackTest, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null" in the "Default" context in the location "C: \ arkiv \ Bartrack \ BartrackTest \ x86 \ Src \ BartrackTest \ bin \ x86 \ Release \ BartrackTest.exe "."}

Any ideas would be appreciated.

+8
dll com
source share
2 answers

Try unregistering any previous version and make sure the DLL is in the same folder as the executable. Also try to see exactly where you are loading the dll. I think you download it manually, so look at the address to which you are referencing the wrong DLL.

+1
source share

Perhaps this is due to the fact that in the case when you use the same version of the .net framework, the instance returned to the client is no longer a COM shell, but a pure .Net object, so when you try to pass its COM interface, working. There is a similar question here. The solution involves the use of a primary interaction assembly .

+1
source share

All Articles