對不起,有些可能是非常基本的問題。我只是想用一個字符串替換UNC路徑。這些線與用於C中的UNC路徑++連接完美的工作原理:嘗試用字符串替換UNC路徑時出錯
[DllImport(C:\\Users\\SJ\\Documents\\VS2015\\Projects\\P_01\\Debug\\EV_01.dll",
EntryPoint = "DDentry", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern void DDentry
(
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)]
string[,] pArrayStr
);
由字符串替換的UNC路徑給出「的對象引用是所必需的非靜態字段,方法或屬性」
錯誤string UNCpath = @"C:\\Users\\SJ\\Documents\\VS2015\\Projects\\P_01\\Debug\\EV_01.dll";
[DllImport(UNCpath,
EntryPoint = "DDentry", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern void DDentry
(
[MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)]
string[,] pArrayStr
);
爲你的想法很多感謝..
可能重複[傳遞一個自定義屬性作爲參數的變量值](https://stackoverflow.com/questions/13125046/passing-a-custom-attribute-with-a-variable-value-as- a參數) – Diado