I tried to use the Unmanaged Exports library (.NET DllExport) in the hope that with its help you will be able to use your DLL without the .net framework .

Example:

 [return: MarshalAs(UnmanagedType.LPWStr)] [DllExport("Test", CallingConvention = CallingConvention.Cdecl)] public static string Test( [MarshalAs(UnmanagedType.LPWStr)] string firstName, [MarshalAs(UnmanagedType.LPWStr)] string lastName) { return string.Format("Hello {0} {1}", firstName, lastName); } 

I connected my DLL to the program in Delphi , but when I called the method, I got an error that the .net framework missing

As I understand it, my DLL should become (unmanaged code) and work without the .net framework . Am I right, or do I not fully understand the point?

    1 answer 1

    Code written in C # is compiled into an intermediate IL code for a .NET virtual machine and can only be executed by it. Therefore, when you run your application on another machine, it cannot be executed in any way without the .NET framework.

    If I understand correctly, the Unmanaged Exports library (.NET DllExport) only adds names for export, but it does not affect the IL code itself. Therefore, its use does not help run it on a machine without a framework.

    To make this approach work, you need to force the compiler to translate the IL code for the virtual machine into the native code for the processor. I didn’t see such functionality, but they write to EnSO about .NET Native which knows how to do it and is included in VS2015.