Load class from registry using COM works with ToolsVersion="2.0" but failes with ToolsVersion="4.0"
Asked Answered
C

1

11

I have a c# project which use an internal vb project as COM.

When I converted the project to VS 2010 the following line Throw me an exception:

Set RTCClient_ = New RTCCORELib.RTCClient

the RTCCore.RTCClient is part of Microsoft Merge Module for RTC (RTC Client API 1.2) that you can embedded into your installation package (That in my case includes the EXE).

the RTCCore.RTCClient is the class that is being registered to registry under HKEY_CLASSES_ROOT\RTCCore.RTCClient

The error I'm getting is:

ERROR: Automation error
The specified module could not be found. (-2147024770)

But If I'm changing my csproj and using ToolsVersion="2.0" the above line works and I can get RTCClient object.

What seems to be the problem?

Contrabandist answered 20/9, 2012 at 7:46 Comment(9)
may you show how do you call your COM object from C#Alderney
I think there's some information missing from your question. Please clarify what RTCCORELib.RTCClient is; confirm whether the VB project itself implements a COM server; and explain the role of the C# project and how it relates to this VB code specifically.Honestly
"confirm whether the VB project itself implements a COM server; and explain the role of the C# project and how it relates to this VB code specifically" - I still don't see this in your edited question.Honestly
My crystal ball says: "Remove On Error Resume Next from that code so you'll get a proper diagnostic"Filide
The ball is still talking: "That's error code 0x8007007E, a Windows error code. It means 'file not found' when trying to load a DLL". Lots of reasons why a DLL could not be found, a typical reason is forgetting to use the /codebase option when you run Regasm.exe to register the C# assembly. You can use SysInternals' ProcMon utility to see where it is looking for the DLL.Filide
@HansPassant My 8-ball telling me that my question is why in ToolsVersion="2.0" my code succeed to create the object and in ToolsVersion="4.0" it failed, what is the differenceContrabandist
@DorCohen If you suspect there is some difference in the build process between "2.0" and "4.0" you can change, in Visual Studio 2010, the output verbosity (for example to "Diagnostic") via "Tools -> Options -> Project and Solutions -> Build and Run -> MSBuild project build output verbosity".Sofiasofie
How is your internal VB project related if the RTCCore library is provided by Microsoft?Sacksen
@DorCohen Can you try setting the useLegacyV2RuntimeActivationPolicy in the application's app.config and see if it helps? : msdn.microsoft.com/en-us/library/bbx34a2h%28v=vs.100%29.aspxNutrition
G
1

Try setting Embed Interop Types to false in the properties of the reference to your COM library in the project. Mine is C#, but your VB.Net may have it as well.

Properties window

Geranium answered 4/10, 2012 at 1:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.