exception HRESULT: 0x800700C1 when executing c# application referencing native c++ lib with boost

↘锁芯ラ 提交于 2019-12-06 18:45:14

问题


I am running a C# application that references a C++\CLI wrapper project which in turn references a native c++ project dependent on Boost 1.47 library (links to files of the form ...vc100-mt-gd-1_47.lib)

All libraries are statically linked and everything compiles great. Executing the C# app results in an exception: "...is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)." claiming some dependency is missing somewhere.

C# application is configured to x86 platform while all other projects are Win32, including boost's binaries.

EDIT: before adding the use of Boost library, it DID work

How can I track down the problem?


回答1:


It is known issue. The reason is Thread Local Storage (TLS) used in the Boost::Thread. To fix it you should either disable libboost_thread-vcXXX-mt-1_XX.lib and force linker to link your C++/CLI assembly with boost_thread-vcXXX-mt-1_XX.lib (stub of the boost_thread-vcXXX-mt-1_XX.dll).

Or you can create your own DLL and link it with libboost_thread-vcXXX-mt-1_XX.lib. Then you can link your C++ DLL with C++/CLI assembly.

See

  • Using boost threads when compiling with /clr
  • Boost Threads with CLR
  • Using boost in CLR



回答2:


Came across this nasty error the other day whilst trying to get an IIS app running on my Visat 64bit PC:

Error: Is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

Solution:

Within IIS 7 click on Application Pools (left hand side under {machine_name}) Select your app pool and then click Advanced Settings on the right. Second setting in the list: Enable 32-Bit Applications - must be set to True.



来源:https://stackoverflow.com/questions/8092869/exception-hresult-0x800700c1-when-executing-c-sharp-application-referencing-nat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!