C
cecille
I have a C++ program that is giving me a CString type of data.
But I have a C# DLL that accepts a String input in its argument.
I need to access that C# dll that accepts a String parameter in the C++
program. but how can I pass the CString input into the C# dll.
I have created a managed C++ code to be able to connect the C++ application
and the C# DLL
but I dont know how to pass the parameters that will be accepted by my C#
dll.
Please look into the code below
Ex.
C# code
public class myClass
{
private string _property1;
private string _property2;
public string Property1
{
set{
_property1 = value;
}
get{
return _property1;
}
}
public string Property2
{
set{
_property2 = value;
}
get{
return _property2;
}
}
public Void SomeMethod()
{
dosomething ( Property1,out Pproperty2);
my code implementation here...
}
}
Unmanaged C++ Code
void CMethod::MyMethod()
{
CString input
SomeMethod(i dont know how to pass the input to this manage C++
method);
}
Manage C++ code
__declspec(dllexport) void _cdecl SomeMethod(i dont know what to put in here
that I can pass the CString input)
{
Call my C# MyClass
myClass::SomeMethod method1;
method1.Property1=(this should be the Input string )
}
If i put it this way
__declspec(dllexport) void _cdecl SOmeMethod(char* input, Char** &
retValue)
{
Call my C# MyClass
myClass::SomeMethod method1;
method1.Property1=input;
retValue = method1.Property2;
}
I will get the following errors :
1. Error C2664:''myClass::SomeMethod:roperty1::set':cannot convert
parameter 1 from 'char *' to 'Systems::String^'
2.Error C2440:'+':cannot convert from 'System::Collections::Arraylist^' to
'char **'
please help.
thanks
But I have a C# DLL that accepts a String input in its argument.
I need to access that C# dll that accepts a String parameter in the C++
program. but how can I pass the CString input into the C# dll.
I have created a managed C++ code to be able to connect the C++ application
and the C# DLL
but I dont know how to pass the parameters that will be accepted by my C#
dll.
Please look into the code below
Ex.
C# code
public class myClass
{
private string _property1;
private string _property2;
public string Property1
{
set{
_property1 = value;
}
get{
return _property1;
}
}
public string Property2
{
set{
_property2 = value;
}
get{
return _property2;
}
}
public Void SomeMethod()
{
dosomething ( Property1,out Pproperty2);
my code implementation here...
}
}
Unmanaged C++ Code
void CMethod::MyMethod()
{
CString input
SomeMethod(i dont know how to pass the input to this manage C++
method);
}
Manage C++ code
__declspec(dllexport) void _cdecl SomeMethod(i dont know what to put in here
that I can pass the CString input)
{
Call my C# MyClass
myClass::SomeMethod method1;
method1.Property1=(this should be the Input string )
}
If i put it this way
__declspec(dllexport) void _cdecl SOmeMethod(char* input, Char** &
retValue)
{
Call my C# MyClass
myClass::SomeMethod method1;
method1.Property1=input;
retValue = method1.Property2;
}
I will get the following errors :
1. Error C2664:''myClass::SomeMethod:roperty1::set':cannot convert
parameter 1 from 'char *' to 'Systems::String^'
2.Error C2440:'+':cannot convert from 'System::Collections::Arraylist^' to
'char **'
please help.
thanks