Search:
Namespaces
Discussions
.NET v1.1
Feedback
.NET Interace fails for no interface
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.framework.interop
.
Post a new message to this list...
Mike Carr
I have a c# component that I have created that has a single interface. I would like to be able to use in from a Visual C++ 6.0 program.
C# component
public class TestExec : ITestExec{
public TestExec()
{
}
#region ITestExec Members
public int initializeTestApp(object wrapper, string resFile, string chksum, string comPort)
{
// TODO: Add TestExec.initializeTestApp implementation
return 0;
}
[InterfaceType(
ComInterfaceType
.InterfaceIsIUnknown)]
public interface ITestExec
{
int initializeTestApp(object wrapper,string resFile, string chksum, string comPort);
}
#endregion
C++ Code
::ITestExecPtr m_pTestExec;
m_pTestExec.CreateInstance("TestExec");
CLSIDFromProgID(clsidString, &clsid) returns CLSID_TestExec
hr = CoCreateInstance(rclsid, pOuter, dwClsContext, __uuidof(IUnknown), reinterpret_cast<void**>(&pIUnknown)); //returns 0
hr = pIUnknown->QueryInterface(GetIID(), reinterpret_cast<void**>(&m_pInterface)); fails for -2147467262
GetIID() returns _com_IIID<ITestExec,&_GUID_d9d79824_7ff6_11d3_abc0_0008c7d32dd0>::GetIID returned {IID_ITestExec}
Can anyone help me out?
--
MICHAEL CARR
Reply to this message...
Mike Carr
I am trying to implement existing interfaces
--
MICHAEL CARR
"Mike Carr" <
Click here to reveal e-mail address
> wrote in message news:%23k%
Click here to reveal e-mail address
...
I have a c# component that I have created that has a single interface. I would like to be able to use in from a Visual C++ 6.0 program.
C# component
public class TestExec : ITestExec{
public TestExec()
{
}
#region ITestExec Members
public int initializeTestApp(object wrapper, string resFile, string chksum, string comPort)
{
// TODO: Add TestExec.initializeTestApp implementation
return 0;
}
[InterfaceType(
ComInterfaceType
.InterfaceIsIUnknown)]
public interface ITestExec
{
int initializeTestApp(object wrapper,string resFile, string chksum, string comPort);
}
#endregion
C++ Code
::ITestExecPtr m_pTestExec;
m_pTestExec.CreateInstance("TestExec");
CLSIDFromProgID(clsidString, &clsid) returns CLSID_TestExec
hr = CoCreateInstance(rclsid, pOuter, dwClsContext, __uuidof(IUnknown), reinterpret_cast<void**>(&pIUnknown)); //returns 0
hr = pIUnknown->QueryInterface(GetIID(), reinterpret_cast<void**>(&m_pInterface)); fails for -2147467262
GetIID() returns _com_IIID<ITestExec,&_GUID_d9d79824_7ff6_11d3_abc0_0008c7d32dd0>::GetIID returned {IID_ITestExec}
Can anyone help me out?
--
MICHAEL CARR
Reply to this message...
Mike Carr
I got it to work finally by adding
ComSourceInterfaces(typeof(ITestExec))]
to my class.
I have one other problem, I keep getting "Run-Time Check Failure #0 - The
value of ESP was not properly saved across a function call. This is usually
a result of calling a function declared with one calling convention with a
function pointer declared with a different calling convention."
The call should look like this:
HRESULT _stdcall pingPhone([out, retval] int* pVal);
but it looks like this:
HRESULT _stdcall pingPhone([out, retval] long* pRetVal);
How can I get the out,retcal = int*, I have been playing with the MarshalAs
with no luck
--
MICHAEL CARR
"Mike Carr" <
Click here to reveal e-mail address
> wrote in message
news:%
Click here to reveal e-mail address
...
I am trying to implement existing interfaces
--
MICHAEL CARR
"Mike Carr" <
Click here to reveal e-mail address
> wrote in message
news:%23k%
Click here to reveal e-mail address
...
I have a c# component that I have created that has a single interface. I
would like to be able to use in from a Visual C++ 6.0 program.
C# component
public class TestExec : ITestExec{
public TestExec()
{
}
#region ITestExec Members
public int initializeTestApp(object wrapper, string resFile, string chksum,
string comPort)
{
// TODO: Add TestExec.initializeTestApp implementation
return 0;
}
[InterfaceType(
ComInterfaceType
.InterfaceIsIUnknown)]
public interface ITestExec
{
int initializeTestApp(object wrapper,string resFile, string chksum, string
comPort);
}
#endregion
C++ Code
::ITestExecPtr m_pTestExec;
m_pTestExec.CreateInstance("TestExec");
CLSIDFromProgID(clsidString, &clsid) returns CLSID_TestExec
hr = CoCreateInstance(rclsid, pOuter, dwClsContext, __uuidof(IUnknown),
reinterpret_cast<void**>(&pIUnknown)); //returns 0
hr = pIUnknown->QueryInterface(GetIID(),
reinterpret_cast<void**>(&m_pInterface)); fails for -2147467262
GetIID() returns
_com_IIID<ITestExec,&_GUID_d9d79824_7ff6_11d3_abc0_0008c7d32dd0>::GetIID
returned {IID_ITestExec}
Can anyone help me out?
--
MICHAEL CARR
Reply to this message...
System.Runtime.InteropServices.ComInterfaceType
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