Visual c++ 错误C3699:&x27^';:无法对类型';使用此间接寻址;std::string';

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,

我试图从我的应用程序中访问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, 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,因为这是正确的“语言”标记