ironpython调用c dll_在IronPython中加载模块

当我在研究这个问题时,我偶然发现了我认为是答案的答案(这只是一个尝试和错误,所以如果我错了,我很乐意被纠正!)在

Python中的import语句更类似于C中的using 语句。您仍然需要加载相关的.dll程序集。C在编译时通过使用引用来实现这一点;IronPython默认包含标准的CLR引用,这就是为什么import System.Xml

但是,如果要加载默认情况下未包含在IronPython中的.dll,则必须使用clr.AddReference("myAssembly.dll")和,然后使用import语句导入模块。在

例如:import clr

clr.AddReferenceToFileAndPath(r"..\lib\umbraco.dll")

import umbraco

umbraco模块现在可由IronPython访问

注意:visualstudio插件“Python工具”允许您添加对Python项目的引用,但是使用引用仍然需要上述步骤。在Visual Studio projects support adding references to projects and extensions. Typically they indicate dependencies between projects and are used to provide IntelliSense at design time or linking at compile time. Python Tools for Visual Studio also uses references in a similar fashion, but due to the dynamic nature of Python they are primarly used at design time to provide improved IntelliSense.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值