[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

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

Jan Obrestad

6/4/2007 8:16: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.

Has anybody experienced anything like this?
1 Answer

TDC

6/8/2007 1:06:00 PM

0

Whene ever I see this:

> 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.

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

Tom