/// <summary> /// Call this from Application_End in your Global.asax.cs file. Besides this call, there should be no other code in the method. /// </summary> public static void CleanUpStatics() { if (!ewlInitialized) { return; } if (!AppTools.SecondaryInitFailed) { EwfApp.ExecuteWithBasicExceptionHandling( () => { if (appInitializer != null) { appInitializer.CleanUpStatics(); } }, false, false); } AppTools.CleanUp(); if (!EwfApp.FrameworkInitialized) { var waitHandle = new ManualResetEvent(false); initFailureUnloadTimer.Dispose(waitHandle); waitHandle.WaitOne(); } }
private static int Main(string[] args) { AppTools.Init("Development Utility", true, new GlobalLogic()); try { return(AppTools.ExecuteAppWithStandardExceptionHandling( () => { try { if (args.Count() < 2) { throw new UserCorrectableException("You must specify the installation path as the first argument and the operation name as the second."); } // Get installation. var installationPath = args[0]; DevelopmentInstallation installation; try { installation = getInstallation(installationPath); } catch (Exception e) { throw new UserCorrectableException("The installation at \"" + installationPath + "\" is invalid.", e); } // Get operation. var operations = AssemblyTools.BuildSingletonDictionary <Operation, string>(Assembly.GetExecutingAssembly(), i => i.GetType().Name); var operationName = args[1]; if (!operations.ContainsKey(operationName)) { throw new UserCorrectableException(operationName + " is not a known operation."); } var operation = operations[operationName]; if (!operation.IsValid(installation)) { throw new UserCorrectableException("The " + operation.GetType().Name + " operation cannot be performed on this installation."); } operation.Execute(installation, new OperationResult()); } catch (Exception e) { Output.WriteTimeStampedError(e.ToString()); if (e is UserCorrectableException) { throw new DoNotEmailOrLogException(); } throw; } })); } finally { AppTools.CleanUp(); } }
/// <summary> /// Call this from Application_End in your Global.asax.cs file. Besides this call, there should be no other code in the method. /// </summary> protected void ewfApplicationEnd() { if (!ewlInitialized) { return; } AppTools.CleanUp(); if (!initialized) { var waitHandle = new ManualResetEvent(false); initFailureUnloadTimer.Dispose(waitHandle); waitHandle.WaitOne(); } }