Visual c++ 错误C3699:&x27^';:无法对类型';使用此间接寻址;std::string';
我试图从我的应用程序中访问lync,在此代码中,我遇到错误Visual c++ 错误C3699:&x27^';:无法对类型';使用此间接寻址;std::string';,visual-c++,c++-cli,Visual C++,C++ Cli,我试图从我的应用程序中访问lync,在此代码中,我遇到错误 error C3699: '^' : cannot use this indirection on type 'std::string' error C2440: 'initializing' : cannot convert from 'System::String ^' to 'std::string *' 1> No user-defined-conversion operator available,
error C3699: '^' : cannot use this indirection on type 'std::string'
error C2440: 'initializing' : cannot convert from 'System::String ^' to 'std::string *'
1> No user-defined-conversion operator available, or
1> Cannot convert a managed type to an unmanaged type
我的代码如下:
#using <Microsoft.Lync.Model.dll>
#using <Microsoft.Lync.Utilities.dll>
//namespace provided that DLL
using namespace Microsoft::Lync::Model;
//Function which is using that DLL
void getusername()
{
LyncClient ^lyncClient;
string ^text=lyncClient->Self->Contact->GetContactInformation(ContactInformationType::DisplayName)->ToString();
}
#使用
#使用
//命名空间提供了该DLL
使用名称空间Microsoft::Lync::Model;
//使用该DLL的函数
void getusername()
{
LyncClient^ LyncClient;
string^text=lyncClient->Self->Contact->GetContactInformation(ContactInformationType::DisplayName)->ToString();
}
ToString()
正在返回托管的系统::字符串类型。这与非托管的std::string
类型不同
要从一个转换到另一个,请使用。在您有的地方使用名称空间std代码>立即停止,再也不要这样做。它是您将text
声明为std::string
而不是System::string
的东西。这可以解决这两个错误。另外,请确保标记C++-CLI,因为这是正确的“语言”标记