我有一個由c#代碼從Windows服務應用程序運行c#控制檯應用程序的問題。從Windows服務運行基於COM的c#控制檯應用程序(c#)
我使用Windows服務作爲每個時間間隔運行任務(Quartz庫)的後臺工作者。
這裏運行其他的C#控制檯應用程序
ps = new ProcessStartInfo(batchRunnerPath);
ps.UseShellExecute = false;
ps.CreateNoWindow = true;
ps.RedirectStandardError = true;
ps.RedirectStandardOutput = true;
ps.Verb = "runas";
var process = Process.Start(ps);
string error = process.StandardError.ReadToEnd();
process.WaitForExit();
控制檯應用程序正在使用COM對象和它呈現PDF文件和圖像,但它事doenst工作的代碼。
當我運行控制檯應用程序exe文件manualy它完美的作品,但是當我嘗試從這個工人運行它我得到一個異常
System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID {22FBECF5-10A3-11D2-9194-204C4F4F5020} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at JDA.Intactix.Automation.SpacePlanning..ctor(Boolean bIKSBRVMenuParam)
at ReportRunner.Program.Main(String[] args) in E:\CFT\PgRunner\BatchRunner\Program.cs:line 98
從我看到這名工人正在啓動這個控制檯應用程序(因爲我在控制檯應用程序中用log4net記錄一些信息),但是在98行,我創建了新的COM對象,它給出了錯誤。
繼承人如何我運行窗口服務 enter image description here
和繼承人給出arror一個碼 - 線=新SpacePlaning(假)給出arror
SpacePlanning sp = null;
ProSpace.Project currentProject = null;
ProSpace.PrintSetup printSetup = null;
var plnLogic = Container.Resolve<Strategix.sCentralPlugin.SPPlugin.SPLogic.IPlanogramLogic>();
try
{
sp = new SpacePlanning(false);
聽起來像權限,是作爲一個帳戶運行的Windows服務,可以執行該控制檯應用程序,它作爲該用戶成功運行? – Bearcat9425