私は長時間実行されるサービスであるアプリケーションを持っています。最近、プラグインとアプリドメインを使用してメモリの問題を解決するように書き直しました。書き直した後、コンソール モードでは問題なく動作しますが、アプリケーションをサービスとして実行できなくなりました。アプリケーションを起動しようとすると、Windows イベント ログに次の例外が記録されます。
Application: ADImport.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.BadImageFormatException
Stack:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at ADImportPlugIn.LoadAssemblyAttributesProxy.LoadAssemblyAttributes(String assFile)
at ADImportPlugIn.LoadAssemblyAttributesProxy.LoadAssemblyAttributes(System.String)
at ADImportPlugIn.PlugInLoader.GetAssemblyNames()
at ADImportPlugIn.PlugInLoader.LoadAllPlugIns()
at ADImport.Program.WorkerMethod()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
ここで検索したところ、アプリケーションのビット数に関する多くのスレッドと、アプリケーションと関連する DLL/アセンブリとの間の不一致の可能性が見られました。私はすべてをチェックし、特定のプラットフォームなどをターゲットにしようとしましたが、何も機能していないようです. 私の開発プラットフォームは 64 ビット Windows 7 で、ターゲットは Windows 2008 64 ビットです。私のアプリケーションは x86 に設定されています。アセンブリは anycpu ですが、x86、x64 などにも設定しようとしました。DLL の 1 つで log4net を使用していますが、それが問題だとは思いません。
どんな助けでも大歓迎です!