2014-05-15 74 views
2

我試圖在此代碼中訪問我的應用程序中的lync我收到錯誤消息。錯誤C3699:'^':無法在類型'std :: string'上使用此間接尋址方式

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(); 
    } 
+3

某處你有'使用命名空間標準;'立即停止,不要再做一次。你將'text'聲明爲'std :: string'而不是'System :: String'。這解決了這兩個錯誤。 – crashmstr

+0

此外,請確保您標記C++ - CLI,因爲這是正確的「語言」標記 – crashmstr

回答

3

ToString()返回一個管理System::String類型。這與非託管std::string類型不同。

要從一個轉換到另一個,請使用marshal_as

相關問題