Created
April 28, 2011 11:58
-
-
Save lpalli/946218 to your computer and use it in GitHub Desktop.
Utility to work with ESRIRegAsm.exe tool.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// The ArcGIS products. | |
/// </summary> | |
public enum Product { | |
/// <summary> | |
/// ArcGIS Desktop | |
/// </summary> | |
Desktop, | |
/// <summary> | |
/// ArcGIS Engine | |
/// </summary> | |
Engine | |
} | |
/// <summary> | |
/// Register or unregister an assembly. | |
/// </summary> | |
/// <param name="register"><code>true</code> to register, <code>false</code> to unregister the class</param> | |
/// <param name="assemply">the assembly</param> | |
/// <param name="product">the product for witch the assembly must be registred</param> | |
/// <param name="timeout">the timeout</param> | |
public static void Execute(bool register, Assembly assemply, | |
Product product = Product.Desktop, int timeout = 10000) | |
{ | |
// Configure the process to execute the command | |
Process process = new Process(); | |
process.StartInfo.FileName = Path.Combine( | |
Environment.GetFolderPath( | |
Environment.SpecialFolder.CommonProgramFiles), | |
"ArcGIS\\bin\\ESRIRegAsm.exe"); | |
process.StartInfo.Arguments = string.Format( | |
register ? "\"{0}\" /p:{1} /s" : "\"{0}\" /p:{1} /u /s", | |
assemply.Location, product); | |
// Invoke the process | |
process.Start(); | |
process.WaitForExit(timeout); | |
// Finish | |
int exitCode = process.ExitCode; | |
process.Close(); | |
if (exitCode != 0) | |
{ | |
throw new Exception(register ? "ESRI registration failed" : | |
"ESRI unregistration failed"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment