COM Messenger dll in c# throws an exception "No such interface supported "

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
(1) Here is the *.odl file for XXXComp.dll (c++ code)
// XXXComp.odl : type library source for XXXComp.dll
[ uuid(0835364C-C7B2-11d3-918A-00C04F797331), version(1.0) ]
library RSS1Comp<br/>
{<br/>
importlib("stdole32.tlb");
// Primary dispatch interface for CCompare<br/>
<br/>
[ uuid(0835364D-C7B2-11d3-918A-00C04F797331) ]<br/>
dispinterface IRSS1Comp<br/>
{<br/>
properties:<br/>
// NOTE - ClassWizard will maintain property information here.<br/>
// Use extreme caution when editing this section.<br/>
//{{AFX_ODL_PROP(IRSS1Comp)<br/>
//}}AFX_ODL_PROP<br/>
<br/>
methods:<br/>
// NOTE - ClassWizard will maintain method information here.<br/>
// Use extreme caution when editing this section.<br/>
//{{AFX_ODL_METHOD(IRSS1Comp)<br/>
[id(1)] void SetDataSelect(boolean bDataSelect);<br/>
[id(2)] void SetLadderSelect(boolean bLadderSelect);<br/>
[id(3)] void SetForceSelect(boolean bForceSelect);<br/>
[id(4)] void SetOverwriteOutput(boolean bOverwriteOutput);<br/>
[id(5)] void SetReportType(short sReportType);<br/>
[id(6)] void SetSrc1File(BSTR szSrc1File);<br/>
[id(7)] void SetSrc2File(BSTR szSrc2File);<br/>
[id(8)] void SetSrc1Title(BSTR szSrc1Title);<br/>
[id(9)] void SetSrc2Title(BSTR szSrc2Title);<br/>
[id(10)] void SetOutputFile(BSTR szOutputFile);<br/>
[id(11)] void SetStatusMutex(long nStatusMutex);<br/>
[id(12)] void SetStartNotify(long nStartEvent);<br/>
[id(13)] void SetStatusBlock(long pStatusBlock);<br/>
[id(14)] void SetFinishNotify(long nFinishEvent);<br/>
[id(15)] BSTR GetErrorString(long nErrorID);<br/>
[id(16)] long StartCompare(short sType); <br/>
//}}AFX_ODL_METHOD
};
// Class information for CCompare
[ uuid(0835364E-C7B2-11d3-918A-00C04F797331) ]<br/>
coclass RSS1Comp<br/>
{<br/>
[default] dispinterface IRSS1Comp;<br/>
};
<br/>
// Primary dispatch interface for CCompDlg<br/>
<br/>
[ uuid(0835364F-C7B2-11d3-918A-00C04F797331) ]<br/>
dispinterface IRSS1CompDlg<br/>
{<br/>
properties:<br/>
// NOTE - ClassWizard will maintain property information here.<br/>
// Use extreme caution when editing this section.<br/>
//{{AFX_ODL_PROP(CCompDlg)<br/>
//}}AFX_ODL_PROP<br/>
<br/>
methods:<br/>
// NOTE - ClassWizard will maintain method information here.<br/>
// Use extreme caution when editing this section.<br/>
//{{AFX_ODL_METHOD(CCompDlg)<br/>
//}}AFX_ODL_METHOD
};
// Class information for CCompDlg
[ uuid(08353650-C7B2-11d3-918A-00C04F797331) ]<br/>
coclass RSS1CompDlg<br/>
{<br/>
[default] dispinterface IRSS1CompDlg;<br/>
};
//{{AFX_APPEND_ODL}}<br/>
//}}AFX_APPEND_ODL}}<br/>
};
Build this c++ project, the output files are XXXComp.dll and XXXComp.tlb .
(2) use tlbimp XXXComp.tlb. the outputfile is RSS1Comp.dll .
(3) Add RSS1Comp.dll to C# reference , and
regsvr32 XXXComp.dll .
<br/>
(4) C# code:
RSS1Comp.RSS1CompClass cmp = new RSSComp.RSS1CompClass();<br/>
<br/>
cmp. SetForceSelect (true);
Throw the following error when call SetForeSelect(true):<br/>
Unable to cast COM object of type RSS1Comp.RSS1CompClass to interface type RSS1Comp.IRSS1Comp. This operation failed because the QueryInterface call on the COM component for the interface with IID {0835364D-C7B2-11D3-918A-00C04F797331} failed due to the
following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
How to resolve this issue?
Thanks in Advance!


<br/>
<br/>
<br/>

View the full article
 
Back
Top