Using a .net compiled dll inside native c++

前端 未结 5 1547
陌清茗
陌清茗 2021-01-07 11:31

as i understand that any .NET program gets compiled to MSIL which is fed to the CLR which compiles it to the assembly code and along with the help of JIT it executes it.

相关标签:
5条回答
  • 2021-01-07 11:39

    It's not a supported way and many features (like Reflection) rely on metadata provided at a higher level than raw machine code. There are some programs (called .NET linkers) that might help, but they are not 100% reliable.

    0 讨论(0)
  • 2021-01-07 11:41

    You can use the Native Image Generator (Ngen.exe) to compile a MSIL DLL to a native code DLL, but this will not allow you to run it on a system without the .NET Framework. You will still have references to other DLLs of the framework and even if you include these DLLs, it will not work on a system without the .NET framework, because the framework is more than just a collection of DLLs.

    0 讨论(0)
  • 2021-01-07 11:45

    If you poke around on the web, I think there are a number of tools to 'compile' .NET assemblies/code to remove their need of the framework. Not sure how well they work....

    0 讨论(0)
  • 2021-01-07 11:53

    This project will allow you to make unmanaged exports .NET of static methods.

    0 讨论(0)
  • 2021-01-07 11:58

    This KB article explains a way to call managed methods from native code. However, you still need to have the .NET framework.

    0 讨论(0)
提交回复
热议问题