C 中除錯C 的Dll

2021-04-14 01:06:37 字數 936 閱讀 9084

被c#呼叫的dll一般只需要把匯出的函式以適當的形式呈現即可呼叫,比如

extern "c" __declspec(dllexport)

bool integrate3 (),這樣的函式,在c#裡面宣告如:

[dllimport("***.dll", callingconvention = callingconvention.stdcall, charset = charset.unicode)]

public static extern bool integrate3();,這裡的呼叫相對是簡單的,而有些資料型別則必須通過marshalas來做託管型別的轉換,如:

extern "c" __declspec(dllexport)

bool integrate (lpcwstr file1, lpcwstr file2, lpcwstr outputfile)

由於資料型別不一致,所以在宣告時要注意把型別轉換過來。

[dllimport("***.dll", callingconvention = callingconvention.stdcall, charset = charset.unicode)]

public static extern bool integrate([in, marshalas(unmanagedtype.lpwstr)]string file1,

[in, marshalas(unmanagedtype.lpwstr)]string file2, [in, marshalas(unmanagedtype.lpwstr)]string outputfile);

這樣呼叫基本是沒有問題,重點在於資料型別的轉換。多試過幾次了就不問題了。

另外乙個小小的實踐經驗就是在c#中除錯c++的dll,知道了就是一句話,不知道就要搞半天,在c#專案屬性中「啟用除錯項」中一項:「啟用非託管**除錯」,鉤上這個,就萬事大吉了,就像你除錯一般的程式一樣。

C 中呼叫 除錯C 的DLL

被c 呼叫的dll一般只需要把匯出的函式 以適當的形式呈現即可呼叫,比如 extern c declspec dllexport bool integrate3 這樣的函式,在c 裡面宣告如 dllimport dll callingconvention callingconvention.stdc...

C 中呼叫 C 編寫的 dll 的 除錯

以下只是針對vs2005,其他版本沒試過 前提 必須有該dll 的c 原始碼 斷點處 被執行 c 程式呼叫c 寫的dll 1.確保工程為debug,而不是release 2.將該dll設為啟動項 3.設定該dll的屬性,property debugging debugger type 為 nativ...

在c 中呼叫並除錯C 的DLL

被c 呼叫的dll一般只需要把匯出的函式以適當的形式呈現即可呼叫,比如 extern c declspec dllexport bool integrate3 這樣的函式,在c 裡面宣告如 dllimport dll callingconvention callingconvention.stdca...