私は単純なC++/CLIコンソールアプリケーションを持っていて、別のプロセスを開始し、それをSTDOUTとSTDERRと読みます。外部(サードパーティ)ライブラリを使用します。私はスタンドアロンを展開可能にするために.exeイメージに埋め込むようにしています。IlMergeの後のC++/CLIアプリケーションエラー
IlMerge出力:少し私を混乱させた
ilmerge /log /out:test1.exe test.exe ILMerge version 2.12.803.0 Copyright (C) Microsoft Corporation 2004-2006. All rights reserved. ILMerge /log /out:test1.exe test.exe Set platform to 'v2', using directory 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\..\v2.0.50727' for mscorlib.dll Running on Microsoft (R) .NET Framework v2.0.50727 mscorlib.dll version = 2.0.0.0 The list of input assemblies is: test.exe Trying to read assembly from the file 'test.exe'. Successfully read in assembly. There were no errors reported in test's metadata. Checking to see that all of the input assemblies have a compatible PeKind. test.PeKind = ILonly, Requires32bits All input assemblies have a compatible PeKind value. Using assembly 'test' for assembly-level attributes for the target assembly. Merging assembly 'test' into target assembly. Copying 4 Win32 Resources from assembly 'test' into target assembly. Transferring entry point '.mainCRTStartupStrArray(System.String[])' from assembly 'test' to assembly 'test1'. There were no errors reported in the target assembly's metadata. ILMerge: Writing target assembly 'test1.exe'. AssemblyResolver: Assembly 'test' is referencing assembly 'Microsoft.VisualC'. AssemblyResolver: Attempting referencing assembly's directory. AssemblyResolver: Did not find the assembly in referencing assembly's directory. AssemblyResolver: Attempting input directory. AssemblyResolver: Did not find the assembly in the input directory. AssemblyResolver: Attempting user-supplied directories. AssemblyResolver: No user-supplied directories. AssemblyResolver: Attempting framework directory. Can not find PDB file. Debug info will not be available for assembly 'Microsoft.VisualC'. Resolved assembly reference 'Microsoft.VisualC' to 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\..\v2.0.50727\Microsoft.VisualC.dll'. (Used framework directory.) Location for referenced module 'KERNEL32.dll' is '' Location for referenced module 'MSVCR100.dll' is '' Location for referenced assembly 'mscorlib' is 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorlib.dll' There were no errors reported in mscorlib's metadata. Location for referenced assembly 'System' is 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\system.dll' There were no errors reported in System's metadata. Location for referenced assembly 'Microsoft.VisualC' is 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Microsoft.VisualC.dll' There were no errors reported in Microsoft.VisualC's metadata. ILMerge: Done.
一つのこと - ソースアプリケーションのx86プラットフォームを考慮しFramework64ライブラリの使用。 test1.exeの
スタートアップはコンソールで次の出力につながる:
Unhandled Exception: System.TypeInitializationException: The type initializer for '' threw an exception. ---> .ModuleLoadException: The C++ module failed to load during registration for the unload events. ---> System.TypeInitializationException: The type initializer for ".ModuleUninitializer" threw an exception. ---> System.MissingMethodException: Method not found: "Void System.Threading.Monitor.Enter(System.Object, Boolean ByRef)". in System.Runtime.CompilerServices.RuntimeHelpers.PrepareDelegate(Delegate d) in System.AppDomain.add_DomainUnload(EventHandler value) in .ModuleUninitializer..ctor() in f:\dd\vctools\crt_bld\self_x86\crt\src\minternal.h:line 255 in .ModuleUninitializer..cctor() in f:\dd\vctools\crt_bld\self_x86\crt\src\minternal.h:line 217 --- End of inner exception stack trace --- in .RegisterModuleUninitializer(EventHandler handler) in f:\dd\vctools\crt_bld\self_x86\crt\src\minternal.h:line 292 in .LanguageSupport.InitializeUninitializer(LanguageSupport*) in f:\dd\vctools\crt_bld\self_x86\crt\src\mstartup.cpp:line 426 in .LanguageSupport._Initialize(LanguageSupport*) in f:\dd\vctools\crt_bld\self_x86\crt\src\mstartup.cpp:line 545 in .LanguageSupport.Initialize(LanguageSupport*) in f:\dd\vctools\crt_bld\self_x86\crt\src\mstartup.cpp:line 697 --- End of inner exception stack trace --- in .ThrowModuleLoadException(String errorMessage, Exception innerException) in f:\dd\vctools\crt_bld\self_x86\crt\src\minternal.h:line 194 in .LanguageSupport.Initialize(LanguageSupport*) in f:\dd\vctools\crt_bld\self_x86\crt\src\mstartup.cpp:line 707 in .cctor() in f:\dd\vctools\crt_bld\self_x86\crt\src\mstartup.cpp:line 749 --- End of inner exception stack trace ---
任意のアイデア?
さらに追加しました:私はサードパーティのライブラリをemdeddingした後に同じプロブレムを持っていて、IlMerge 。 –
ILMergeを使用しないで、代わりに['AppDomain.CurrentDomain.AssemblyResolve'と埋め込みリソースを使用する](https://blogs.msdn.microsoft.com/microsoft_press/2010/02/03/jeffrey-richter-excerpt-2 -from-clr-via-c-third-edition /)。 ILMergeの著者であるMike Barnettはこの記事についてコメントし、そのトリックについて知っていれば、まずILMergeを書かなかったでしょう。 [Fody/Costura](https://github.com/Fody/Costura)を使用すると、ビルドプロセス中に自動化することができます。 –
@Scott AssemblyResolveの動作はILMergeとはまったく異なります(一例として「内部」アクセシビリティを持つメンバーへのアクセスを考慮してください) –