全部我有一些C#DLL,我想在運行時使用System.Reflection
從我的應用程序調用。我使用的核心代碼是一樣的東西通過反射將參數數組傳遞給C#DLL
DLL = Assembly.LoadFrom(Path.GetFullPath(strDllName));
classType = DLL.GetType(String.Format("{0}.{0}", strNameSpace, strClassName));
if (classType != null)
{
classInstance = Activator.CreateInstance(classType);
MethodInfo methodInfo = classType.GetMethod(strMethodName);
if (methodInfo != null)
{
object result = null;
result = methodInfo.Invoke(classInstance, parameters);
return Convert.ToBoolean(result);
}
}
我想知道我怎麼能參數數組中傳遞給DLL作爲ref
,這樣我可以提取出來的DLL裏面發生了什麼信息。我想要什麼(但當然不會編譯)的清晰寫照將是
result = methodInfo.Invoke(classInstance, ref parameters);
我該如何做到這一點?
可能會有所幫助:http://stackoverflow.com/questions/1551761/ref-parameters-and-reflection – Dennis