1
リフレクションを使用して2つのアセンブリをロードしてから、それらからいくつかのタイプを使用しています。アセンブリを読み込んだ後、型を読み込んでActivatorで型をインスタンス化した後、 "LoadFromXml"メソッドを呼び出そうとすると、アセンブリでFileNotFound例外が発生します。これは以前は動いていて、何が変わったのか分かりません。また、問題なく作成されたインスタンスからプロパティを取得できます。メソッド "LoadFromXml"を呼び出すときに例外をスローします。アセンブリを正常にロードした後にファイルが見つかりません
private static object CheckForVersion(int version, string constructFilePath, string utilityFilePath)
{
if (!System.IO.File.Exists(constructFilePath) || !System.IO.File.Exists(utilityFilePath) || version < 7) return null;
var utilAssembly = System.Reflection.Assembly.LoadFile(utilityFilePath);
var constructAssembly = System.Reflection.Assembly.LoadFile(constructFilePath);
var InfoManager = utilAssembly.GetType(String.Format("{0}.InfoManager", utilAssembly.FullName.Split(',')[0]));
var ExecutionServerPropertiesConstructType = constructAssembly.GetType(String.Format("{0}.ExecutionServerPropertiesConstruct", constructAssembly.FullName.Split(',')[0]));
string dbFolder = (string)(InfoManager.GetProperty("ServerDatabaseFolder").GetValue(null, null));
if (Directory.Exists(dbFolder) == true)
{
string FilePath = Path.Combine(dbFolder, @"ExecutionServer.config.xml"); //DONT LOCALIZE
dynamic theServerProperties = Activator.CreateInstance(ExecutionServerPropertiesConstructType);
theServerProperties.LoadFromXml(FilePath);
var retVal = new
{
InstalledProductVersion = version,
ServerGuid = (string)InfoManager.GetField("SERVER_GUID").GetValue(null),
WorkflowRootnodeGuid = (string)InfoManager.GetField("WORKFLOW_ROOTNODE_GUID").GetValue(null),
TaskRootnodeGuid = (string)InfoManager.GetField("TASK_ROOTNODE_GUID").GetValue(null),
TriggerRootnodeGuid = (string)InfoManager.GetField("TRIGGER_ROOTNODE_GUID").GetValue(null),
ProcessRootnodeGuid = (string)InfoManager.GetField("PROCESS_ROOTNODE_GUID").GetValue(null),
ConnectionString = theServerProperties.ConnectionString
};
return Newtonsoft.Json.JsonConvert.SerializeObject(retVal);
}
return null;
}