Activex interop in windows forms - problem registering library
-
Thursday, February 23, 2012 10:23 AM
Hello,
I try to embed in Windows Forms a third party application which has also activex interop dlls. I have the following case.
The application exposes one activex proxy interop component (name it "a" and filename AxInerop.a.dll ). It also has another activex interop component that is the "real one" (name it b and filename AxInerop.b.dll). The doc says that I should access the component only through the proxy (a) and not b which is can be used by VB mainly. Also there are some other interop dlls (not activex) that are the libraries (interfaces mostly) that access the unmanaged code. So there is one that is the main library (name it c with name c.dll ). This dll depends on another wrapper library (name it d). However d's filename is Interop.d.dll and also exists a d.tlb .
I can drag "a" activex into my form correctly. Then I have to pass in the activex control as argument an object of c. When I try to create an object (through inerface) of c (name it myobject) I get the following error:
Unable to cast COM object of type 'System.__ComObject' to interface type '<c.myobject>''. This operation failed because the QueryInterface call on the COM component for the interface with IID '{<c-id>}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
I thought this means that the library (c) is not registered. So I try to register it myself with regasm. However the registration fails with error that the dependent library d does not exist
RegAsm : error RA0000 : Could not load file or assembly '<d>, Versio
n=1.0.0.0, Culture=neutral, PublicKeyToken=<d public token> or one of its depen
dencies. The system cannot find the file specified.But d only depends to mscorlib and stdole.
So I tried to register inerop.d.dll myself with regasm and it registers correctly, maybe it was already registered. I also registered d.tlb with regtlibv12. But when I try to register again c.dll it still fails with the same message.
I think when I do regasm c.dll, it tries to find a library named d.dll, but only Interop.d.dll and d.tlb exists.
I don't know If have undestood correctly the interop technology and if my terminology is correct as I am new to this.
Do you have any idea of what I can do to solve the problem?
Thank you
All Replies
-
Sunday, February 26, 2012 11:31 AM
Hello,
Do you have any suggestion?
-
Monday, February 27, 2012 2:50 AMModerator
You can try to use TlbImg.exe to convert the type definitions found within a COM type library into equivalent definitions in a common language runtime assembly. Command like this:
tlbimp myTest.tlb /out:myTest.dll
Then register it:
regasm myTest.dll
Reference the dll in project c.
Paul Zhou [MSFT]
MSDN Community Support | Feedback to us
-
Tuesday, February 28, 2012 12:12 PM
Hello,
thank you for your answer. This is what I did lately, but I can't change change assemblyh c, because it is third party. So regasm fails again becuase of different publickeytoken. Should I try to change the reference with a tool like ildams/ilasm? And if so how?
Thank you
-
Tuesday, February 28, 2012 1:42 PM
I manged to register it with regasm after changing making the assemblied strong names and changing the references. However I still get
Unable to cast COM object of type 'System.__ComObject' to interface type '<c.myobject>''. This operation failed because the QueryInterface call on the COM component for the interface with IID '{<c-id>}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
The c-id doesn't exist in the registry. Other IIDs and CLSIDs exist that reference library c. Strange eh?
And why does it ask for IID and not CLSID?
-
Tuesday, February 28, 2012 2:04 PMThe CLSID of the CoClass exists. The IID does not exist. Is there a way to create it my self?
-
Wednesday, February 29, 2012 2:26 AMModerator
If the C-ID doesn't exists in the registry, it proves that the C component has not been registered.
I think you need to ask the author of the component C how to register it.
Paul Zhou [MSFT]
MSDN Community Support | Feedback to us

