Hello
-
Hello, I have a C# dll (COM) which contains API which have a parameter like below :
[type: ComVisible(true)]
[Guid("66F046BC-D97C-4CF2-96B5-01E66329FC65")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface ICDBrowserServiceMgr
{
[DispId(15)]
void Initialize(SeeSPMPLMClientLib.TSeeSPMPLMClient A_pClient);...}
Now I need to integrate this dll in MFC application So I put the import directive
#import "SeeSPMPLMClient.dll" // for the use of ISeeSPMPLMClientPtr
#import "My_dll.tlb" // to use the APIafter i do
My_Dll_Namespace::ICDBrowserServiceMgrPtr m_pICDBrowser;
SeeSPMPLMClientLib::ISeeSPMPLMClientPtr m_pPLMClientMgr;m_pICDBrowser->Initialize(m_pPLMClientMgr);
I ahve the error : error C2664: 'My_Dll::ICDBrowserServiceMgr::Initialize' : cannot convert parameter 1 from 'SeeSPMPLMClientLib::ISeeSPMPLMClientPtr' to 'My_Dll_Namespace::ISeeSPMPLMClient *' Any idea please ?
khaliloenit wrote:
Any idea please ?
As the message says, you cannot pass a
SeeSPMPLMClientLib::ISeeSPMPLMClientPtr
to a method that expects aMy_Dll_Namespace::ISeeSPMPLMClient *
. Check the documentation and the header files to see exactly what you should be passing across.Veni, vidi, abiit domum
-
khaliloenit wrote:
Any idea please ?
As the message says, you cannot pass a
SeeSPMPLMClientLib::ISeeSPMPLMClientPtr
to a method that expects aMy_Dll_Namespace::ISeeSPMPLMClient *
. Check the documentation and the header files to see exactly what you should be passing across.Veni, vidi, abiit domum
-
Er, No; otherwise the compiler would not be producing that error message.
Veni, vidi, abiit domum
-
this is cant be caused by ambiguity of namespaces ? i.e : if this type is used in C# dll and after passed from other project which use same type we have ambiguity of Type ?
-
Hello, I have a C# dll (COM) which contains API which have a parameter like below :
[type: ComVisible(true)]
[Guid("66F046BC-D97C-4CF2-96B5-01E66329FC65")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface ICDBrowserServiceMgr
{
[DispId(15)]
void Initialize(SeeSPMPLMClientLib.TSeeSPMPLMClient A_pClient);...}
Now I need to integrate this dll in MFC application So I put the import directive
#import "SeeSPMPLMClient.dll" // for the use of ISeeSPMPLMClientPtr
#import "My_dll.tlb" // to use the APIafter i do
My_Dll_Namespace::ICDBrowserServiceMgrPtr m_pICDBrowser;
SeeSPMPLMClientLib::ISeeSPMPLMClientPtr m_pPLMClientMgr;m_pICDBrowser->Initialize(m_pPLMClientMgr);
I ahve the error : error C2664: 'My_Dll::ICDBrowserServiceMgr::Initialize' : cannot convert parameter 1 from 'SeeSPMPLMClientLib::ISeeSPMPLMClientPtr' to 'My_Dll_Namespace::ISeeSPMPLMClient *' Any idea please ?
m_pICDBrowser
is a variable of a type defined in the namespaceMy_Dll_Namespace
, therefore the methodInitialize
is also defined in that namespace, and, according to the compiler error message, expects an argument of pointer to a type that's also defined in that namespace. You however pass an argument that's defined in an entirely different namespace,SeeSPMPLMClientLib
- it's a different type.GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
-
m_pICDBrowser
is a variable of a type defined in the namespaceMy_Dll_Namespace
, therefore the methodInitialize
is also defined in that namespace, and, according to the compiler error message, expects an argument of pointer to a type that's also defined in that namespace. You however pass an argument that's defined in an entirely different namespace,SeeSPMPLMClientLib
- it's a different type.GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
As you see above I pass the same type :
public interface ICDBrowserServiceMgr
{
[DispId(15)]
void Initialize(SeeSPMPLMClientLib.TSeeSPMPLMClient A_pClient);...}
and in call
SeeSPMPLMClientLib::ISeeSPMPLMClientPtr m_pPLMClientMgr;
m_pICDBrowser->Initialize(m_pPLMClientMgr);
-
As you see above I pass the same type :
public interface ICDBrowserServiceMgr
{
[DispId(15)]
void Initialize(SeeSPMPLMClientLib.TSeeSPMPLMClient A_pClient);...}
and in call
SeeSPMPLMClientLib::ISeeSPMPLMClientPtr m_pPLMClientMgr;
m_pICDBrowser->Initialize(m_pPLMClientMgr);
You're missing my point. Check the type of
m_pICDBrowser
! the function
Initialize()
you are calling here is not the one you think you are calling!
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
-
You're missing my point. Check the type of
m_pICDBrowser
! the function
Initialize()
you are calling here is not the one you think you are calling!
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
-
Maybe it's best you take another look at the error message you got. In the line
m_pICDBrowser->Initialize(m_pPLMClientMgr);
the error message states that it cannot convert the first parameter in the call (
m_pPLMClientMgr
to the type that the function expects. According to the error message, the type ofm_pPLMClientMgr
isSeeSPMPLMClientLib::ISeeSPMPLMClientPtr
, but the type it expects isMy_Dll_Namespace::ISeeSPMPLMClient *
. This implies, that you have a typeISeeSPMPLMClientPtr
defined somewhere in namespaceSeeSPMPLMClientLib
, but it is not defined as the required typeMy_Dll_Namespace::ISeeSPMPLMClient *
. I suspect that you mixed up the two namespaces. Maybe you inserted ausing namespace
somewhere (always a bad idea), and then you no longer saw what namespace the definitions and types refer to, or maybe you just have a wrong type definition.GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)