我有一个C#控制台应用程序,并希望通过用户输入选择在控制台应用程序运行时加载和执行的特定dll库。那可能吗?加载dll库并在运行时运行代码
因此,举例来说,我可能有2个相同的静态类和动作名称DLL库如下:
public static class CoreStrategy
{
public static Action<List<Quote>> strategyQuoteBuffer = new Action<List<Quote>>(quoteList =>
{
Console.WriteLine("I am dll 1");
});
}
public static class CoreStrategy
{
public static Action<List<Quote>> strategyQuoteBuffer = new Action<List<Quote>>(quoteList =>
{
Console.WriteLine("I am dll 2");
});
}
我如何可以加载其中的一个我的控制台应用程序的运行过程中,并调用它们,然后切换另一个?或者有更好的方法来处理这个问题吗?甚至可能来自Dll的不同方式?要求是每个代码都严格包含在它自己的dll中,而且这些dll不能事先被引用。如果这是不可行的,那么你能够建议一种方式,而不使用dll?谢谢
见http://stackoverflow.com/questions/1087794/c-sharp-load-a-dll-file-and-access-methods-from-class-within – Liron 2012-08-01 15:30:38