Groups | Blog | Home
all groups > dotnet interop > june 2007 >

dotnet interop : COM Interop: One interface fails query interface while another works.



Jan Obrestad
6/4/2007 12:00:00 AM
While developing a .NET module that uses COM to communicate with the
main application, I have seen this strange error.
I have a class that I expose to COM (BookAndPlanFormSupport) this class
implements two interfaces that are also exposed to COM
(IDotNetSupportBase and IDotNetMdiSupport).

The resulting IDL looks like this.

coclass BookAndPlanFormSupport {
interface _Object;
interface IDotNetSupportBase;
[default] interface IDotNetMdiSupport;
};

The problem is that in the c++ code query interface on one of the
interfaces works, on the other it doesn't.

Example code:
#import "WrapperInterfaces.tlb" no_namespace raw_interfaces_only named_guids

IDotNetMdiSupportPtr m_pForm;
IDotNetSupportBasePtr m_pFormBase;

HRESULT hr, hr2

hr =m_pForm.CreateInstance((LPCSTR)"<prefix>.BookAndPlanFormSupport");
hr2=m_pFormBase.CreateInstance((LPCSTR)"<prefix>.BookAndPlanFormSupport");

Here the m_pForm.CreateInstance succeeds, but m_pFormBase.CreateInstance
fails with the error: "The system could not find the file specified".

To make things stranger, this is only a problem when I try to install
the program, when I run it on my development machine everything works fine.

TDC
6/8/2007 6:06:12 AM
Whene ever I see this:

[quoted text, click to view]

The first thing to check is that the TypeLib is correctly registered
on the target machine.

Tom
AddThis Social Bookmark Button