2016-12-01 124 views
0

我有一個C#接口,看起來像這樣:C++/CLI實現一個C#接口

public interface ITdcConnector 
{ 
    void Close(uint); 
    void FetchRequestAsync(ManagedFetchRequest); 
    UInt32 Open(String, Action<uint, ManagedFetchResponse>, out Int64); 
} 

我想用C實現++/CLI是這樣的:

public ref class MockTdcConnector : public ITdcConnector 
{ 
public: 
    virtual Void Close(UInt32); 
    Void FetchRequestAsync(ManagedFetchRequest); 
    UInt32 Open(String, Action<UInt32, ManagedFetchResponse^>^, 
     [System::Runtime::InteropServices::Out] Int64%); 
}; 

智能感知是給我在Open()方法上的悲傷。它告訴我:IntelliSense: class fails to implement interface member function "ITdcConnector::Open"

我已經看過在C++/CLI中實現C#類的few relevant examples,但沒有運氣。有關如何讓C++/cli方法簽名看起來像C#方法的想法?

+0

@HansPassant謝謝您的回答,但我得到了它,下面。 –

回答

0

所以,直到現在我纔看到這一點。我開始在C++/cli類中輸入C#方法的名稱,IntelliSence顯示了它期望的方法簽名。我只需要更多的^ s和virtual s。

這裏是我結束了使用,以供將來參考:

public ref class MockTdcConnector : public ITdcConnector 
{ 
public: 
    virtual Void Close(UInt32); 
    virtual Void FetchRequestAsync(ManagedFetchRequest^); 
    virtual UInt32 Open(String^, Action<UInt32, ManagedFetchResponse^>^ 
     [Runtime::InteropServices::Out] Int64%); 
};