We have a Managed VC++ .exe (for 4.5 Framwork) file that was built using ILMerge. The exe is working perfectly fine when compiled with 32 bit platform configuration. However, we are getting the following TypeInitializationException when compiled with 64 bit configuration:
Unhandled Exception: System.TypeInitializationException: The type initializer fo
r '<Module>' threw an exception. ---> <CrtImplementationDetails>.ModuleLoadExcep
tion: The C++ module failed to load during vtable initialization.
---> System.ArgumentOutOfRangeException: Token 0 is not valid in the scope of m
odule System.ModuleHandle.
Parameter name: metadataToken
at System.ModuleHandle.ResolveMethodHandleInternalCore(RuntimeModule module,
Int32 methodToken, IntPtr[] typeInstantiationContext, Int32 typeInstCount, IntPt
r[] methodInstantiationContext, Int32 methodInstCount)
at System.ModuleHandle.ResolveMethodHandleInternal(RuntimeModule module, Int3
2 methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[]
methodInstantiationContext)
at System.ModuleHandle.ResolveMethodHandle(Int32 methodToken, RuntimeTypeHand
le[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at <CrtImplementationDetails>.ThisModule.ResolveMethod<void const * __clrcall
(void)>(IntPtr methodToken) in f:\dd\vctools\crt_bld\self_64_amd64\crt\src\purem
silcode.cpp:line 154
at _initterm_m((fnptr)* pfbegin, (fnptr)* pfend) in f:\dd\vctools\crt_bld\sel
f_64_amd64\crt\src\puremsilcode.cpp:line 218
at <CrtImplementationDetails>.LanguageSupport.InitializeVtables(LanguageSuppo
rt* A_0) in f:\dd\vctools\crt_bld\self_64_amd64\crt\src\mstartup.cpp:line 332
at <CrtImplementationDetails>.LanguageSupport._Initialize(LanguageSupport* A_
0) in f:\dd\vctools\crt_bld\self_64_amd64\crt\src\mstartup.cpp:line 546
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* A_0
) in f:\dd\vctools\crt_bld\self_64_amd64\crt\src\mstartup.cpp:line 703
--- End of inner exception stack trace ---
at <CrtImplementationDetails>.ThrowModuleLoadException(String errorMessage, E
xception innerException) in f:\dd\vctools\crt_bld\self_64_amd64\crt\src\minterna
l.h:line 194
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* A_0
) in f:\dd\vctools\crt_bld\self_64_amd64\crt\src\mstartup.cpp:line 713
at .cctor() in f:\dd\vctools\crt_bld\self_64_amd64\crt\src\mstartup.cpp:line
754
--- End of inner exception stack trace ---