.NET Automation
| |
| |
| static FormMain() |
| { |
| AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler); |
| } |
| |
| |
| |
| |
| public static Assembly MyResolveEventHandler(object sender, ResolveEventArgs args) |
| { |
| |
| |
| |
| foreach (AssemblyName strAssmbName in Assembly.GetExecutingAssembly().GetReferencedAssemblies()) |
| { |
| |
| if (((strAssmbName.Name.EndsWith("CommonMiddle")) |
| )) |
| { |
| |
| AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(MyResolveEventHandler); |
| object regKeyValue; |
| |
| |
| regKeyValue = Registry.GetValue(Registry.CurrentUser + @"\Software\Intergraph\SP3D\Installation", "INSTALLDIR", ""); |
| if (regKeyValue == null) |
| { |
| regKeyValue = Registry.GetValue(Registry.LocalMachine + @"\Software\Intergraph\SP3D\Installation", "INSTALLDIR", ""); |
| } |
| |
| if (regKeyValue == null) |
| { |
| regKeyValue = Registry.GetValue(Registry.CurrentUser + @"\Software\Wow6432Node\Intergraph\SP3D\Installation", "INSTALLDIR", ""); |
| } |
| |
| if (regKeyValue == null) |
| { |
| regKeyValue = Registry.GetValue(Registry.LocalMachine + @"\Software\Wow6432Node\Intergraph\SP3D\Installation", "INSTALLDIR", ""); |
| } |
| |
| if (regKeyValue == null) |
| { |
| throw new Exception("Error Reading SmartPlant 3D Installation Directory from Registry !!! Exiting"); |
| } |
| |
| string sInstallPath = regKeyValue.ToString(); |
| |
| if (!sInstallPath.EndsWith(@"\")) |
| { |
| sInstallPath = sInstallPath + @"\"; |
| } |
| |
| sInstallPath = sInstallPath + @"Core\Container\Bin\Assemblies\Release\"; |
| |
| |
| return Assembly.LoadFrom(sInstallPath + "CommonMiddle.dll"); |
| } |
| } |
| |
| return null; |
| } |
댓글
댓글 쓰기