无法从 C# 项目引用 IronPython 项目

发布于 2024-10-09 21:44:52 字数 203 浏览 0 评论 0原文

我正在尝试在 C# 项目中引用 IronPython 项目。它们都在同一个解决方案中。我是 IronPython 的新手,所以我只是想知道引用是如何工作的。 IronPython 是否生成程序集?我想做的就是将一个简单的类拉到 C# 项目中。

有什么想法吗?

谢谢。

编辑:我没有收到任何错误,我只是不知道如何引用 Ironpython 项目。

I am trying to reference an IronPython project in a C# Project. They are both in the same solution. I am new to IronPython, so I was just wondering how the referencing works. Does an IronPython generate an assembly at all? All Im trying to do is a pull a simple class into the C# project.

any ideas?

Thanks.

Edit: I'm not getting any error, I just cannot figure out how to reference the Ironpython project.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

乖不如嘢 2024-10-16 21:44:52

如果您使用 IronPython Tools for Visual Studio,则不会编译 IronPython 项目。要将 IronPython 代码编译为 .NET 程序集,您可以使用 IronPython 命令行编译器 pyc 或 SharpDevelop。

如果没有托管 IronPython 运行时的应用程序,则无法直接从 C# 应用程序使用已编译的 IronPython 程序集。当 C# 应用程序托管 IronPython 运行时时,您可以使用 IronPython 脚本文件 (.py) 或编译的 IronPython 程序集,如下面两篇文章中所述,这两篇文章都使用 IronPython 2.6。

  1. 使用 .NET 中的 Python 类
  2. 使用 .NET 中编译的 Python 类

第一篇文章展示了一个示例,其中 IronPython 代码与C# 代码。您也可以通过使用 CreateScriptSourceFromFile 替换对 CreateScriptSourceFromString 的调用或使用 .NET Framework 从文件加载 IronPython 代码。

If you are using IronPython Tools for Visual Studio then an IronPython project will not be compiled. To compile IronPython code to a .NET assembly you can use the IronPython command line compiler pyc or SharpDevelop.

A compiled IronPython assembly cannot be used from a C# application directly without the application hosting the IronPython runtime. When the C# application hosts the IronPython runtime you can then either use the IronPython script files (.py) or the compiled IronPython assembly, as explained in the two articles below, both of which use IronPython 2.6.

  1. Using Python Classes from .NET
  2. Using Compiled Python Classes from .NET

The first article shows an example where the IronPython code mixed in with the C# code. You can alternatively load the IronPython code from files by replacing the call to CreateScriptSourceFromString with CreateScriptSourceFromFile or by using the .NET Framework.

烟若柳尘 2024-10-16 21:44:52

据我所知,IronPython 仅创建 .py 脚本文件 - 您可以在运行时通过 DLR 访问代码,有一个示例 此处

As far as I know IronPython only creates .py script files - you can access the code through the DLR at runtime, there's an example for that here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文