Using free registration in a .NET application.

I am trying to use a third-party COM-DLL (I do not believe its .NET component) from a .NET service without registering a COM library, but I have not been lucky so far.

I copied the manifest files from here (http://stackoverflow.com/questions/465882/generate-manifest-files-for-registration-free-com) for use as a starting point (I generated a COM DLL using the reference file mt.exe /regsvr42.exe). However, all I get is the following error:

Exception: System.InvalidCastException Message: Cannot pass COM object of type "LOGICLib.LogicClass" to interface type "LOGICLib.ILogic". This operation failed because the call to the QueryInterface COM component for the IID interface '{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAA3E8FB4}' failed due to the following error: this interface is not supported (exception from HRESULT: 0x80004002 (E_NOINTERFACE) ), Source: Interop.LOGICLib in LOGICLib.LogicSecuredClass.Connect (String IP, UInt16, Int32 & Result) in My.Server.MyAssembly.Loader.Connect () in D: \ MyProject \ Source \ Server \ MyAssembly \ Loader. cs: line 461

In the application manifest after exe, which starts the service, I also tried to give it a name after the assembly, which calls the COM-DLL. I tried running on the command line and through the Visual Studio debugger. I also tried using a third-party Interop file and generating my own.

(Note: I tested only under Windows XP.)

I spent two days on this now and did not advance at all. Any ideas that I might have missed?

+4
source share
2 answers

The application identifier is named after exe, which starts the service

Yes it does not work. Windows is always looking for a manifest in the EXE itself, implemented as an unmanaged resource. Only when he cannot find it will he search for the .manifest file on disk. The problem is that the managed program built with VS2008 and already has a manifest. By default, they say only "I know only Vista."

You can verify this yourself using File + Open + File and selecting EXE. Open RT_MANIFEST node and double-click resource 1. If you do not see COM manifest entries without permission, it will not work.

To fix, use Project + Add New Item and select the application manifest item template. You will get a template manifest, copy and paste your COM register entries there.

+3
source

Well, due to an exception, you get an error when you try to apply an object of type LogicClass to an ILogic interface type. LogicClass does not seem to implement ILogic.

You did not specify what the DLL is or where you got it, so it’s best to look at the documentation for the library that you are trying to use. Just a wild guess, but it looks like you are implementing it incorrectly.

-1
source

Source: https://habr.com/ru/post/1336144/


All Articles