私は、アセンブリを読み込んで別のappdomainで実行する必要があるデスクトップアプリケーションで作業しています。私のように書かれているアセンブリのロードのためにタイプまたは名前空間名が見つかりませんでした
:
public static DataTable GetAllPluginNames(string[] args)
{
SqlConnection sConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
//ToDo: create a table of one column - only name of the plugin and return that.
//ToDo: refer the code from MFAssemblyValidator from MFPluggerService.
DataTable dt = null;
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 IMFDBAnalyserPlugin.
if (oType.GetInterface("IMFDBAnalyserPlugin") == typeof(IMFDBAnalyserPlugin))
{
assemblyNames.Add(args[assemblyCount].Substring(args[assemblyCount].LastIndexOf("\\") + 1));
}
}
return dt;
}
catch (Exception ex)
{
lblError.Text = "ERROR";
}
// Passing data one application domain to another.
AppDomain.CurrentDomain.SetData("AssemblyNames", assemblyNames.ToArray());
}
}
しかしtypeof(IMFDBAnalyserPlugin))
は、名前空間のエラーを示しています。
IMFDBAnalyserPluginはとして私のプログラムのインターフェイスクラスです:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MFDBAnalyser
{
public interface IMFDBAnalyserPlugin
{
void ExecutePlugin();
}
}
何が問題かもしれません? 誰も私を助けることができます!
それはあまりにもうまくいきません.... – Srivastava
あなたはコードで使用するたびに 'IMFDBAnalyserPlugin' *の完全修飾リファレンスを提供する必要があります。ただし、' using'ディレクティブをコードファイルの先頭私は完全な構文で自分の投稿を更新しました。 –