hi...I got solution after initializing stInfo..Thank u soooooooooooooooooooo much.....Thanks for ur helping heart...

Could u plzzzzzzzz help me to solve another one problem...


i have one dll created by using C#.Net...I refered that dll and i could access all the C# methods inside my VC++ applications..

this is the method which i have written in C# (I compiled this method to dll)
ReturnValue(string key,string value)
{
.......
.......
}

i have a vc++ code like

CString getValue=ReturnValue("RegNo","Dept");

then i could get the value...

But if i give like :
CString value="RegNo";
CString key="Dept";

and if i pass the parameter like:

CString getValue=ReturnValue(value,key); i am getting the following error...


Error 1 error C2664 cannot convert parameter 1 from 'CString' to 'System::String ^'

Recommended Answers

All 15 Replies

Hi friends,
i have one dll created by using C#.Net(I should not write in vc++ thats my requirement)...I referred that dll in vc++ applications and i could access all the C# methods inside my VC++ applications..

this is the method which i have written in C# (I compiled this method to dll)
ReturnValue(string key,string value)
{
.......
.......
}

i have a vc++ code like

CString getValue=ReturnValue("RegNo","Dept");

then its working perfectly and i could get the value...

But if i give like :
CString value="RegNo";
CString key="Dept";

and if i pass the parameter like:

CString getValue=ReturnValue(value,key); i am getting the following error...


Error 1 error C2664 cannot convert parameter 1 from 'CString' to 'System::String ^'

Could anyone help me in this...

Well, lose the CString.

System::String value = "RegNo";
System::String key = "Dept";

System::String /* assuming */ getValue = ReturnValue(value, key);

Read my post in your other thread.

i didnt get that i want reply here itself

Well, lose the CString.

System::String value = "RegNo";
System::String key = "Dept";

System::String /* assuming */ getValue = ReturnValue(value, key);

No. It wants a System::String^ (note the ^)

But to solve the problem, you should use std::strings

#include <string>
...
std::string ReturnValue(std::string key,std::string value)
{
.......
.......
}
...
std::string value = "RegNo";
std::string key = "Dept";

std::string  getValue = ReturnValue(value, key);

hi thanks for responding me..i tried with us code but i got error Error 1 error C2664:cannot convert parameter 1 from 'std::string' to 'System::String ^'...Kndly help me... sherin

Could you post the entire code?

No. It wants a System::String^ (note the ^)

But to solve the problem, you should use std::strings

C# doesn't have STL. .NET has System::String and all that.

What's the ^ for anyway?

Hi..Thanks for responding me...

this is VC++ code:

//////////////////////////
CString f="offnen";
CString f1="de|en";
std::string g=TranslatingService::TranslateLanguage::TranslateText(std::string(f) ,std::string(f1));
/////////////////////////


This translateText is the method present in in translationservice dll  developed in C#.Net [Which i have referred from Vc++].


The following is the C# translating Service dll code:
////////////////////////////
namespace TranslatingService
{
public class TranslateLanguage
{
public  static string TranslateText(string input, string languagePair)
{



.........
........


return result;


}
}
}


/////////////////////////

kindly help me... sherin

Error 1 error C2664: 'TranslatingService::TranslateLanguage::TranslateText' : cannot convert parameter 1 from 'std::basic_string<_Elem,_Traits,_Ax>' to 'System::String ^'

i got this error after executing the above code...

Hi..Thanks for responding me...

this is VC++ code:
//////////////////////////
std::string ofnen="OPen";

std::string often="de|en";

std::string t= TranslatingService::TranslateLanguage::TranslateText(std::string(f) ,std::string(f1));

/////////////////////////

This translateText is the method present in in translationservice dll developed in C#.Net [Which i have referred from Vc++].

The following is the C# translating Service dll code:
////////////////////////////
namespace TranslatingService
{
public class TranslateLanguage
{
public static string TranslateText(string input, string languagePair)
{


.........
........

return result;

}
}
}

/////////////////////////

cannot convert parameter 1 from 'std::basic_string<_Elem,_Traits,_Ax>' to 'System::String ^' in VC++ kindly help me... sherin

commented: > 10 posts and no code tags - feel the red -4

try something like:

System::String^ ofnen  = gcnew System::String("OPen");

System::String^ often = gcnew System::String("de|en");

System::String t =  TranslatingService::TranslateLanguage::TranslateText(ofnen, often);

Remember, std::string is C++-specific, System::String is .NET-specific, and portable to the .NET languages (Managed C++ and C#).

String ^test=gcnew System :: String(LPCTSTR(source));

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.