0
我必須創建一個類,它將從存儲庫中加載所有的dll,並檢查它們是否從IMFServicePlugin接口繼承並返回 有效的dll。 ,我用這個做...在WinForms應用程序中獲取DLL
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms.ComponentModel;
using MFDBAnalyser;
namespace MFDBAnalyserAssemblyValidator
{
public class MFDBAnalyserAssemblyValidator
{
static void Main(string[] args)
{
List<string> assemblyNames = new List<string>();
Assembly[] oAssemblies = new Assembly[args.Length];
for (int assemblyCount = 0; assemblyCount < args.Length; assemblyCount++)
{
oAssemblies[assemblyCount] = Assembly.LoadFile(args[assemblyCount]);
try
{
foreach (Type oType in oAssemblies[assemblyCount].GetTypes())
{
// Check whether class is inheriting from IMFServicePlugin.
if (oType.GetInterface("IMFDBAnalyserPlugin") == typeof(IMFDBAnalyserPlugin))
{
assemblyNames.Add(args[assemblyCount].Substring(args[assemblyCount].LastIndexOf("\\") + 1));
}
}
}
catch (Exception ex)
{
lblError.Text = "ERROR";
}
}
// Passing data one application domain to another.
AppDomain.CurrentDomain.SetData("AssemblyNames", assemblyNames.ToArray());
}
}
}
但這是從庫中加載的dll,但我也想存儲在另一個ORM類這些DLL。
任何人都可以幫助我... 如果可能的話,請提供一些鏈接,以便我可以充分了解dll如何適用於Windows /桌面應用程序。
「這是爲了從存儲庫中加載dll,但我也想將這些dll存儲在另一個ORM類中」,您可以添加更多關於此的信息嗎? – TalentTuner 2010-11-19 11:30:02