2011-07-15 8 views
1

Webサイトとwinformアプリケーションの両方で使用されているC#アセンブリがあります。このdllの一部には、オプションのプラグインdllが存在するかどうかをチェックし、存在する場合はそれを使用する機能があります。これは、一致するインターフェイスを持つdllのローカルフォルダをスキャンすることによって機能します。だから、何が起こるかの省略形は次のとおりです。IIS7の下で実行している場合iis7でのプラグインアセンブリの検出

Assembly executingAssembly = Assembly.GetExecutingAssembly(); 
foreach (FileInfo dllFile in exeLocation.GetFiles("*.dll")) 
{ 
    assembly = Assembly.LoadFile(dllFile.FullName); 
    foreach (Type exportedType in assembly.GetExportedTypes()) 
    { 
    foreach (Type interfaceType in exportedType.GetInterfaces()) 
    { 
     if (interfaceType == typeof(IMyInterface)) 
    { 
     //Found it! 
     } 
    } 
    } 
} 

残念ながら、各DLLがexeLocation.GetFilesので、独自のフォルダに座って\ ASP.NETの一時ファイルの下にシャドウコピーを作成するように見えます単一のdll(それ自身)のみを返します。私はすべてのwinforms、webforms、サービス、等(好ましくはiis7の設定を変更せずに動作する)ソリューションが必要です

アイデア?

答えて

1
DirectoryInfo location; 
if(HttpRuntime.AppDomainAppId != null) { 
    location = new DirectoryInfo(Path.Combine(HttpContext.Current.Server.MapPath("~/bin"))); 
} else { 
    location = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory; 
} 

foreach (var file in location.GetFiles("*.dll")) 
{ 
    // your code 
} 
+0

ありがとうございました。 – Vman

関連する問題