Using dll compilation with .net extension inside embedded C ++

since I understand that any .NET program is compiled into MSIL, which is sent to the CLR, which compiles it to assembler code and runs it with JIT.

I was wondering since .NET is a wrapper around win32 api, and the CLR will eventually convert MSIL to a build program. Is it impossible for me to write some functionality in C #, make it in dll, and then use a tool that makes it a full-fledged .net-independent file for me to use inside unmanaged code, for example, in C or C ++.

Am I talking about Interops and COM? Isn't this idea different from her? My goal is to run the .NET dll on a machine that does not have the .NET framework.

+1
source share
5 answers

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

+1
source

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

+1
source

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

+1
source

This is not supported, and many features (such as Reflection) are based on metadata provided at a higher level than the source machine code. There are some programs (called .NET linkers) that can help, but they are not 100% reliable.

0
source

If you pop up on the Internet, I think there are several tools to compile .NET / code collections to eliminate their structural need. Not sure how well they work.

0
source

Source: https://habr.com/ru/post/1336160/


All Articles