[問題] 如何傳遞 __arglist 給其他 function
internal void foo (string str, __arglist)
{
xxx
}
public void foo2(string str, __arglist)
{
// 請問這邊要如何將其他程式傳進來
// foo2 的 arglist 再傳入 foo ??
foo(str,arglist?);
}
public void Main()
{
int a,b,c;
foo2("ABC",__arglist(out a,out b,out c));
}
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.237.120.118
※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1508045868.A.D58.html
推
10/15 14:26,
7年前
, 1F
10/15 14:26, 1F
沒有找到相關的文件,
// 專案 A
// 目的要在專案 A 中引用 C/C++ 的標準函式,
// 之後的其他專案只要參考專案 A 就可以使用這些函式,
// 不須 [DllImport("")]
// 但如同 A-1 的寫法,在單元測試中總是會出現
// System.BadImageFormatException: 找不到索引
// 但若用 B-1 的寫法(在同專案中),就能夠正常工作
// 而 A-3 foo2 也能夠正常被其他專案呼叫,
// 所以才想說在 A-3 foo2 中再去呼叫 A-1
public static class ExDLL
{
// 程式 A-1
[DllImport("msvcrt40.dll")]
public static extern int sscanf(string str, string format, __arglist);
// 程式 A-2
[DllImport("msvcrt40.dll")]
public static extern int sscanf(string str, string format, out int arg);
// 程式 A-3
public static int foo2(string str, string format, __arglist)
{
}
}
==================================================================
// 專案 B (參考專案 A)
// 程式 B-1
[DllImport("msvcrt40.dll")]
public static extern int sscanf(string str, string format, __arglist);
public void Main()
{
// 分別使用 A-1, A-3, A-2, B-1
// A-1 會產生 System.BadImageFormatException: 找不到索引
// A-2, A-3, B-1 都可以正常工作
// A-1:呼叫其他專案中的 DllImport + __arglist (失敗)
// A-2:呼叫其他專案中的 DllImport (成功)
// A-3:呼叫其他專案中的 __arglist (成功)
// B-1:呼叫本地專案中的 DllImport + __arglist (成功)
}
※ 編輯: noodleT (36.237.120.118), 10/15/2017 16:34:54
推
10/15 23:45,
7年前
, 2F
10/15 23:45, 2F
→
10/15 23:51,
7年前
, 3F
10/15 23:51, 3F
→
10/15 23:52,
7年前
, 4F
10/15 23:52, 4F
→
10/16 07:10,
7年前
, 5F
10/16 07:10, 5F
→
10/16 08:11,
7年前
, 6F
10/16 08:11, 6F
→
10/16 08:18,
7年前
, 7F
10/16 08:18, 7F
推
10/18 20:58,
7年前
, 8F
10/18 20:58, 8F
→
10/18 20:59,
7年前
, 9F
10/18 20:59, 9F
→
10/18 20:59,
7年前
, 10F
10/18 20:59, 10F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章