开发者

Cannot reference IronPython Project from C# Project

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.

开发者_如何学Python

any ideas?

Thanks.

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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜