简体   繁体   English

我可以在非托管Delphi EXE中使用托管C#DLL吗?

[英]Can I use managed C# DLL in unmanaged Delphi EXE?

Can I use managed C# DLL in unmanaged Delphi EXE? 我可以在非托管Delphi EXE中使用托管C#DLL吗? Or the only way is to have managed DLL and EXE or unmanaged DLL and EXE? 或者唯一的方法是拥有托管DLL和EXE或非托管DLL和EXE?

There are quite a few options, including at least the following: 有很多选择,至少包括以下内容:

  1. Expose the classes that you need via COM which can be readily consumed by Delphi. 通过COM公开您需要的类,Delphi可以轻松使用它们。
  2. Create a mixed mode C++/CLI wrapper that uses the C# DLL as a reference. 创建一个混合模式C ++ / CLI包装器,它使用C#DLL作为参考。 That mixed mode DLL can export native functions and you can then consume that DLL using Delphi external . 混合模式DLL可以导出本机函数,然后您可以使用Delphi external使用该DLL。 That is, you consume the DLL just in the same way as Windows system DLLs are consumed. 也就是说,您使用DLL的方式与使用Windows系统DLL的方式相同。
  3. Use Robert Giesecke's UnmanagedExports . 使用Robert Giesecke的UnmanagedExports
  4. Use the CLR's native API to consume the C# DLL directly. 使用CLR的本机API直接使用C#DLL。 This option is probably the least attractive since it's the hardest to get right. 这个选项可能是最不具吸引力的,因为它是最难做到的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM