-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

このシナリオでよくある問題の 1 つは、ユーザーのアクセス許可です。これは、コンソールで実行するユーザーとは異なるユーザーとしてサービスが実行されるためです。しかし、質問に対するコメントから判断すると、すでにチェック済みです。

エラーのもう 1 つの原因は、コンソール アプリケーションの作業ディレクトリが EXE が配置されているディレクトリであるという事実です。Windows サービスでは、そうではありません。作業ディレクトリはC:\Windows\System32(またはどこでも%SYSTEMDIR%)です。そのため、現在の作業ディレクトリに依存するコード (同じディレクトリ内のファイルを読み取るなど) がある場合、それはサービスとして機能しません。確かではありませんが、EXE と同じパスにある COM ライブラリを読み込もうとすると、同じ問題が発生する可能性があります。

だから、私があなたに提案すること:

  • 権限を再確認してください。
  • 相対パスに依存するコードを確認し、代わりに絶対パスに変更してください。
于 2013-09-11T11:29:48.693 に答える