.NETGURU
IDispatch Help
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.interop.

Post a new message to this list...

Mike Carr
I am trying to implement an existing C++ Sink Interface (????).
In the C# initializeTestApp, if I try to cast to WRAPPERLib.IWrapper it
throw and exception. Currently the object that comes across is a
{System.__ComObject} how can I get this to be a pointer to
WRAPPERLib.IWrapper in C#?

Here is the C++ Code:

IUnknownPtr pUnknown;
hr = m_xWrapper.QueryInterface (IID_IUnknown, (void**) &pUnknown); //first
time only

iError = pTestExec->initializeTestApp(pUnknown, //ptr to Wrapper
_bstr_t(szTestAppConfigFilename), //config/resource file
_bstr_t(""), //no config/resource file checksum
comPort);

pTestExec implementation:
WRAPPERLib::IWrapper m_pWrapper ;

STDMETHODIMP CTestExec::initializeTestApp(/*[in]*/ IUnknown *wrapper,
/*[in]*/ BSTR resFile, /*[in]*/ BSTR checkSum, /*[in]*/ BSTR comPort,
/*[out, retval]*/ int *pVal)
{
IUnknownPtr pUnknown;

//==========================================================================
// Save the pointer to the Wrapper

//==========================================================================
try {
m_pWrapper = wrapper;
}
.....

C# Server so far:
[
ComImport,
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("D9D79824-7FF6-11D3-ABC0-0008C7D32DD0")
]
public interface ITestExec
{
int initializeTestApp([MarshalAs(UnmanagedType.IUnknown)]object
wrapper,string resFile, string chksum, string comPort);
.....

}

[Guid("2217BB8C-7352-474c-93B7-B0AE8923AA9F"),
ClassInterface(ClassInterfaceType.AutoDual),
ComSourceInterfaces(typeof(ITestExec),typeof(WRAPPERLib.IWrapper)),
ProgId("MyTestExec.TestExec")]
public class TestExec : ITestExec
{
public int initializeTestApp(object wrapper, string resFile, string chksum,
string comPort)
{
int val =6;
return 0;
}

.....
}

Thanks in advance for your replies..
--
MICHAEL CARR

Reply to this message...
 
    
Mike Carr
m_xWrapper implements:

AddRef()
Release()
QueryInterface (REFIID riid, void** ppv)

plus the actual sink functions:
STDMETHODIMP CCOMTestAdapterApp::XWrapper::raw_sendTestMsg(int transId, BSTR
message)
STDMETHODIMP CCOMTestAdapterApp::XWrapper::raw_sendTestData( int transId,
BSTR functionName,
int loopCntr,
BSTR value,
BSTR upper,
BSTR lower,
BSTR unit,
BSTR dataType,
BSTR failureDescription,
int significantTestData,
BSTR passFailCode
)
.....

--
MICHAEL CARR

"Mike Carr" <Click here to reveal e-mail address> wrote in message
news:OBGH%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Mike Carr
I got it, I had to add my interop assembly into the gac.

--
MICHAEL CARR

"Mike Carr" <Click here to reveal e-mail address> wrote in message
news:%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.Runtime.InteropServices.ClassInterfaceType
System.Runtime.InteropServices.ComInterfaceType
System.Runtime.InteropServices.UnmanagedType




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification