我有一个使用COM库的应用程序。当我在控制台应用程序中运行它进行测试时,它运行良好。但是当我使用installutil将其安装为Windows服务时。在日志中我有错误
Message: (SaveInvoice) - Zapisywanie faktury - FS/12584/2012/01
Nie znaleziono błedu o kodzie: Creating an instance of the COM component with CLSID {F8605331-7454-4A45-98DB-A69EBB3D2947} from the IClassFactory failed due to the following error: 8000ffff Katastrofalny błąd. (0x8000FFFF (E_UNEXPECTED)).
Stacktrace: SaveDocuments.SaveInputDocuments => SaveMethods.SaveInvoice => LogProvider.ErrorException
Exception:
System.Runtime.InteropServices.COMException (0x8000FFFF): Creating an instance of the COM component with CLSID {F8605331-7454-4A45-98DB-A69EBB3D2947} from the IClassFactory failed due to the following error: 8000ffff Katastrofalny błąd. (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)).
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 Rewizor.Application.Start.get_Gt()
at Rewizor.Application.Start.get_Rewizor()
at Rewizor.Parsers.Invoice.InvoiceParser.InvoiceParserVatDocument(CustEDIInvoice invoice)
at Rewizor.ModelRepository.Invoice.InvoiceRepository.CreateInvoice(CustEDIInvoice invoice)
at DALRewizor.RewizorRepository.CreateInvoice(CustEDIInvoice invoice)
at EDIService.BLL.RepositoryBLL.CreateInvoice(CustEDIInvoice invoice)
at BLL.InboxRepository.SaveMethods.SaveInvoice(EDI_OutputStorage item)
任何人都有想法,如何解决?
答案 0 :(得分:0)
此方案中的一个常见问题是用户权限,因为该服务作为与在控制台中运行的用户不同的用户运行。但根据对问题的评论判断,你已经检查了它。
另一个错误来源是控制台应用程序的工作目录是EXE所在的目录。使用Windows服务,它不是;工作目录为C:\Windows\System32
(或%SYSTEMDIR%
所在的位置)。因此,如果您的代码依赖于当前工作目录(例如读取同一目录中的文件),则它将无法作为服务运行。我不确定,但如果您尝试在与EXE相同的路径中加载COM库,可能会出现同样的问题。
所以,我建议你: