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




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