Call C# dll from unmanaged C++ app without COM

前端 未结 4 1603
Happy的楠姐
Happy的楠姐 2021-01-03 02:36

Is there a way to call c# dll from c++ unmanaged application without COM usage?

4条回答
  •  忘掉有多难
    2021-01-03 03:00

    It is actually possible to disassemble, modify the IL, and reassemble it with exported functions. I messed with this a few years ago, and created an application that would disassemble a dll, provide a list of functions that could potentially be exported - allowing the user to select them, then re-write the IL and reassemble everything. Then, I could call directly into the dll from unmanaged code...or p-invoke into the dll from managed code (not really practical, but interesting nonetheless).

    Surely there is a reason that this isn't supported in the .net languages themselves (even tho it is supported in MSIL). I wouldn't use this in production:

    Dead link: http://www.csharphelp.com/2007/03/exporting-managed-code-as-unmanaged/

    Wayback Machine: https://web.archive.org/web/20140213030149/http://www.csharphelp.com/2007/03/exporting-managed-code-as-unmanaged/

提交回复
热议问题