다른 프로세스를 시작하고 STDOUT 및 STDERR을 읽는 간단한 C++/CLI 콘솔 응용 프로그램이 있습니다. 외부 (타사) 라이브러리를 사용합니다. 독립 실행 형 배포를 위해 배포 가능하도록 .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 라이브러리의 사용.
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 ---
어떤 아이디어 : test1.exe의
시작 콘솔 출력을 다음에 이르게?
을 사용하여 가져 왔습니다. 추가 : 타사 라이브러리를 emdedding 한 후 동일한 재귀를 사용하고 Ilamerge를 사용하여 .exe 이미지 만 "재조합"하려고했습니다. . –
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와 상당히 다릅니다 (한 예로 "내부"접근성을 가진 멤버에 대한 액세스를 고려하십시오). –