我使用Monotouch包裝的Dll中的某些類存在一些問題。有些方法的Objective-C中的參數類型爲(const char *),我在創建包裝器時將其轉換爲字符串。 目前爲止一切進展順利。問題是我有一個類試圖建立一個到一個url的套接字連接。我創建了一個字符串變量,其中包含url的名稱,但在Dll的生成日誌中,我總是看到特殊字符中的URL,例如「X」,它表示主機名未知。下面是兩種方法中的OBJ-C和C#的例子:在Monotouch中包裝常量char *
- (BOOL) open:(const char*)method withUrl:(const char*)url withAsync:(BOOL)isAsync;
[Export ("open:withUrl:withAsync:")]
bool Open (string method, string url, bool isAsync);
和另一個問題:
- (id)init:(const char*)url onPort:(int)port andUseSSL:(BOOL)ssl;
[Export ("init:onPort:andUseSSL:")]
IntPtr Constructor (string url, int port, bool ssl);
第一種方法代表一個定製的HttpRequest。我甚至試圖使用Encoding.UTF8編碼字符串,但沒有運氣。
有沒有人有一個想法,爲什麼發生這種情況?
由於
可能是垃圾(腐敗)或編碼問題。你能編輯你的問題,並顯示原始定義以及如何將它們轉換爲C#嗎? – poupou 2012-07-19 17:23:43
我編輯了我的問題。感謝poupou。 – Thabet 2012-07-19 17:40:27