Problem reference a com assembly dll
I have a problem. When I import a COM dll (VB6) in my C# appl开发者_开发问答ication, All is fine. It compiles and works.
However when I use the app on an other PC, I have an error message :
Unable to cast an object to COM type Installation.VB6FenetreClass Installation._VB6Fenetre interface type. This operation failed because the QueryInterface call on the COM component for the interface with IID {4CD38B1B-45F1-4DC5-910E-3579664306B9} ' failed due to the following error: this interface is not supported (BingTranslated)
But I don't understand why.
Welcome to DLL hell. The version registered on the computer you are testing on is different from the version on the computer you are developing on (or has a different GUID).
It's a fairly classic sign of DLL Hell. VB6 generates new interface IIDs when the code is modified. Making it likely that the COM server on the target PC is not the same version as the one you built your program against.
Finally I've found the problem. Hans and Chuck you're right, the problem is my VB6 DLL was not referenced.
When I compile my VB6 DLL, Visual Basic 6.0 registers my DLL automatically in the registry base (Thing that I didn't notice before).
And in Visual Studio 2005, I didn't see there is a reference to my VB6 DLL because when I reference it, VS generates an other DLL (if the name of my dll is MYDLL, VS generates a Interop.MYDLL.dll).
So I thought there was only a reference at Interop.MYDLL.dll and not a reference to MYDLL.dll too.
In consequence, we have to copy the VB6 DLL, the .NET DLL on the client computer. Then we have to register the VB6 DLL with the following command :
regsvr32 MYDLL.DLL
精彩评论