請原諒我只是爲了掌握這些術語,我在這裏是C#知識的邊緣,需要尋求指導。我有一個DLL,其中包括兩個類和一個窗體(附加類)其中一個類的工作項具有公共(字符串名稱,int ID)。填充列表<things>在反映外部dll類
// in the DLL:
public class workitems {
public string name {get;set;}
public int id{get;set;}
}
主力類具有多種功能
// in the DLL:
public class workhorse {
List<workitems> WorkLoad = new List<workitems>();
public function DoThings() { ..... stuff ...... }
}
在另一程序中使用的變量,我需要調用此DLL(I經由反射假定)。我試過
// in a separate C# script that needs to call this via reflection
Assembly asm = Assembly.LoadFile(thedll);
,但我無法弄清楚如何工作項加載到變量,然後調用從DLL函數與工作項...我越來越糊塗型/班/ methodinfo/.GetType ...任何指導將不勝感激。
從已經調用的DLL文件,我需要做些什麼樣的程序:
otherdll.workload.add(stuff)
otherdll.DoThings(); (which uses the workload from that class)
我很好奇,爲什麼你會說:「我需要調用這個DLL(我通過反思)」。爲什麼不直接引用該dll?可能有一個很好的理由,但是你的問題意味着你由於缺乏知識而選擇了最困難的方式。 – TnTinMn