Loader lock (regsvr32 R6033 error) with managed C++ dll

感情迁移 提交于 2019-12-04 14:57:11

You need to add the /clr compiler flag only to the files that use managed code and not for the whole project.

This is what the Visual Studio "Wizard" does, here is how I've tested:

  • Create a Visual C++ ATL Project
  • Added a ATL Simple Object, in order to have a COM interface (Project->Add Class)
  • Added a CLR Component Class. The Wizard prompted me with "You are adding a CLR component to a native project. Your project will be converted to have Common Language Runtime support."
  • Compile project, compiles fine and registers fine.
  • Checked the project settings -> "No Common Language Runtime support"
  • Checked the clrcomponennt.cpp settings -> "Common Language Runtime Support (/clr)"
  • Opened the dll in OleView -> COM interface was present
  • Opened the dll in Red Gate's .NET Reflector -> clrcomponent was present

Using /clr flag has made your methods managed (ie. they are being compiled down to MSIL), but you're calling them for DllMain which -isn't- managed. Unfortunately, that's about as far as my limited knowledge can take it.

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