-1

我有一个使用 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)

任何人都有想法,如何解决它?

4

1 回答 1

0

这种情况下的常见问题之一是用户权限,因为该服务以不同于在控制台中运行的用户身份运行。但是从对该问题的评论来看,您已经检查过了。

另一个错误来源是控制台应用程序的工作目录是 EXE 所在的目录。对于 Windows 服务,它不是;工作目录是C:\Windows\System32(或任何地方%SYSTEMDIR%)。因此,如果您的代码依赖于当前工作目录(例如读取同一目录中的文件),它将无法作为服务运行。我不确定,但如果您尝试将 COM 库加载到与 EXE 相同的路径中,可能会发生同样的问题。

所以,我建议你:

  • 仔细检查您的权限。
  • 检查任何依赖相对路径的代码并将其更改为绝对路径。
于 2013-09-11T11:29:48.693 回答