ironpython

Ambigious reference for ExtensionAttribute when using Iron Python in Asp.Net

妖精的绣舞 提交于 2019-12-05 08:22:21
问题 I get the following error when starting an Asp.Net site that uses an assembly that in turn makes use of the dlr and Iron Python for scripting. BC30560: 'ExtensionAttribute' is ambiguous in the namespace 'System.Runtime.CompilerServices'. The issue seems to be known and there's a workaround in the issue tracker. However it says that they... ... hope that this workaround will not be necessary in the next release. The latest release (the one that I'm using) is a later release than the one

Does IronPython implement python standard library?

坚强是说给别人听的谎言 提交于 2019-12-05 07:28:10
I tried IronPython some time ago and it seemed that it implements only python language, and uses .NET for libraries. Is this still the case? Can one use python modules from IronPython? The IronPython installer includes the Python standard library. Otherwise, you can use the standard library from a compatible Python install (IPy 2.0 -> CPy 2.5, IPy 2.6 -> CPy 2.6). Either copy the Python Lib directory to the IronPython folder, or set IRONPYTHONPATH. Do note that only the pure Pyton modules will be available; Python modules that require C extensions have to be re-implemented (and most of them

How to unload a .NET assembly reference in IronPython

老子叫甜甜 提交于 2019-12-05 06:09:50
After loading a reference to an assembly with something like: import clr clr.AddRferenceToFileAndPath(r'C:\foo.dll') How can I unload the assembly again? Why would anyone ever want to do this? Because I'm recompiling foo.dll and want to reload it, but the compiler is giving me a fuss, since IronPython is allready accessing foo.dll . .NET itself doesn't support unloading just a single assembly. Instead, you need to unload a whole AppDomain . I don't know exactly how IronPython works with AppDomain s, but that's the normal .NET way of doing things. (Load the assembly into a new AppDomain , use

is F# to IronPython/IronRuby as C# is to VB.NET?

假装没事ソ 提交于 2019-12-05 05:45:43
I just listened to podcast of Chris Smith talking about F# in which he talks about how F# is a language which allows you to approach problems in a different way than in C#/VB.NET, i.e. instead of "pushing bits around" you "chain together data transformations", and that how F# will "become like XML", something that you use in addition to your language of choice (C# or VB.NET) in order to solve certain problems in a more efficient way. This got me to thinking about the relationship of the .NET languages, here's how I understand them: C# and VB.NET are syntactically but not substantially

Accessing C# class members in IronPython

ε祈祈猫儿з 提交于 2019-12-05 03:37:03
In my C# code I have a class which stores some data I wish to pass down to my python code in a List. However, when I try to access properties of that class inside my python code I get MissingMemberException . Here some example code to show what I mean: C#: class Event { public int EventId { get; set; } public string EventName { get; set; } } //other processing here... //this just fills the list with event objects List<Event> eventList = GetEvents(); //this sets a variable in the ScriptScope PythonEngine.SetVariable( "events", eventList); PythonEngine.Execute("eventParser.py"); eventParser.py:

Writing iron python method with ref or out parameter

柔情痞子 提交于 2019-12-05 03:05:45
i need to translate following C# method to the same IronPhyton method private void GetTP(string name, out string ter, out int prov) { ter = 2; prov = 1; } In python (and consequently in IronPython) you cannot change a parameter that is not mutable (like strings) So you can't directly traslate the given code to python, but you must do something like: def GetTP(name): return tuple([2, 1]) and when you call it you must do: retTuple = GetTP(name) ter = retTuple[0] prov = retTuple[1] that is the same behaviour when in IronPython you call a C# method containing out/ref parameters. In fact, in that

Getting traceback information from IronPython exceptions

泄露秘密 提交于 2019-12-05 00:28:28
I have IronPython hosted within my application, whenever I catch an exception thrown from a script, I get unhelpful gibberish like this: IronPython.NewTypes.System.Exception_1$1: Error occurred during conversion ---> Microsoft.Scripting.ArgumentTypeException: expected int, got DispMethod at _stub_$245##245(Closure , CallSite , Object ) at Microsoft.Scripting.Actions.MatchCaller.Call1[T0,TRet](Func`3 target, CallSite site, Object[] args) at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args) at Microsoft.Scripting.Actions.UpdateDelegates.Update1[T,T0,TRet](CallSite site, T0

IronPython exposing .Net type to the runtime engine

只谈情不闲聊 提交于 2019-12-05 00:27:35
问题 I'm looking to expose specific .Net types to the IronPython runtime. I can do this: ScriptEngine engine = Python.CreateEngine(); ScriptScope scope = engine.CreateScope(); engine.Runtime.LoadAssembly(typeof(Program).Assembly); // current assembly with types But that exposes all types to the runtime. Is selective type loading possible? 回答1: No, you must load the entire assembly. This is internally managed by the ScriptDomainManager, which only keeps a list of loaded assemblies, not types. The

IronPython 3 compatibility

放肆的年华 提交于 2019-12-04 23:59:14
I love the Python language and mainly use the standard CPython 3.+ version for simple scripting and as an algorithm sandbox. Sometimes I need .NET intergration, so I use IronPython which is now in 2.7 version. I like 3.+ better and am therefore reluctant to use the older 2.7. Is there any info on when will it be released and how difficult the migration process is expected to be? There is as far as I know no planned release date for 3.0 support in IronPython. The migration process for IronPython 2 -> IronPython 3 is the same as for CPython 2 -> CPython 3, afaik. IronPython has one big step

Referencing Python “import” assemblies when calling from IronPython in C#

核能气质少年 提交于 2019-12-04 22:41:46
I'm a complete noob when it comes to IronPython. I need to call a py script from an ASP.NET website, and have the following code: var ipy = IronPython.Hosting.Python.CreateRuntime(); dynamic test = ipy.UseFile(Server.MapPath(@"~\python\test.py")); test.DoWork(); The version of IronPython I'm using is 2.7. The 3rd party python file I need to call has the following import directives: import sys from array import * from subprocess import * I'm receiving the error "No module named subprocess". I've copied the subprocess.py file from the IronPython installation Lib directory, but I assume I need to