Skip to main content
 首页 » 编程设计

python之是否可以仅通过 dll 访问 .Net 运行时

2025年05月04日10kuangbin

我使用的 PC (Win7) 没有任何 MS 开发工具。但是,此 PC 上安装了 python 2.7。 ctype 模块在此安装中可用。 (它不是 IronPython。它只是普通的 CPython)

现在,如果我们查看 OSX 上的 Objective-C,C 程序可以通过调用 objc_msgSend 和一些其他 API (https://developer .apple.com/library/mac/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html)。这很痛苦,根本不推荐,但至少它是可行的。

那么鉴于上述限制条件(win7,无 VStudio,python+ctype),我是否有可能以类似于 objective-c 的方式访问 .Net 运行时?

请您参考如下方法:

is it possible for me to access the .Net runtime in a manner similar to objective-c?

.NET Runtime can be Hosted ,它允许您直接从 native API 访问和使用类型。

话虽如此,通常有更简单的方法来完成此任务。例如,如果您需要访问的 .NET 类型是 COM 可见的,您可以直接通过 COM 使用它们。