Search:
Namespaces
Discussions
.NET v1.1
Feedback
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
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com