public EngineHolder(string projectId) { try { engineLoader = new OutprocLoader(); // When a process finishes normally, all COM objects are released and work processes hosting these objects also finish // normally. If the process terminates abnormally (hard exception or manually killed) the COM objects are not released // and work processes will remain loaded. To address this issue and make your server more robust you can make // each work process watch if its parent process is still alive and terminate if not. var processControl = (IHostProcessControl)engineLoader; processControl.SetClientProcessId(Process.GetCurrentProcess().Id); process = Process.GetProcessById(processControl.ProcessId); engine = engineLoader.GetEngineObject(projectId); } catch (COMException exception) { var hResult = (uint)exception.ErrorCode; if (hResult == 0x80070005) { // To use LocalServer under a special account you must add this account to // the COM-object's launch permissions (using DCOMCNFG or OLE/COM object viewer) throw new Exception(@"Launch permission for the work-process COM-object is not granted. Use DCOMCNFG to change security settings for the object. (" + exception.Message + ")"); } throw; } isEngineLocked = false; engineUsageCount = 0; }
private AbbyyManager() { engineLoader = new InprocLoader(); engine = engineLoader.GetEngineObject(licens); prepareImageMode = engine.CreatePrepareImageMode(); prepareImageMode.EnhanceLocalContrast = true; }