IronPython fails to import a type which used to reside in system.dll #1776
mjkkirschner
started this conversation in
General
Replies: 1 comment
-
Assemblies are loaded into the using System.Reflection;
using IronPython.Hosting;
var engine = Python.CreateEngine();
engine.Runtime.LoadAssembly(Assembly.Load("System"));
engine.Execute("import clr\nfrom System.Diagnostics import Process"); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am running into a behavior change from .net 4.8 to .net6+
We support our users writing running python in IronPython by hosting a python engine.
Previously in net48 the following code ran successfully:
It nows throws an import exception about the type not existing in the module.
In net48 - this type was present in
system.dll / mscorlib
- it's now been moved tosystem.diagnostics.process.dll
in net6+.I note this snippet from the IronPython docs website.
IronPython only knows about assemblies that have been loaded using one of clr.AddReference-methods. It is possible for other assemblies to already be loaded before IronPython is loaded, or for other assemblies to be loaded by other parts of the application by calling [System.Reflection.Assembly.Load](http://msdn.microsoft.com/en-us/library/system.reflection.assembly.load.aspx), but IronPython will not be aware of these.
If I do
clr.AddReference("System.Diagnostics.Process")
of course it works - though the binary does seem to loaded already in my case which is confusing. (checking in the debug module window)But - ideally I would like to enable our users to make the transition to net6 without needing to touch countless python programs.
import
without usingclr.AddReference
.TypeForwardedTo
attribute. https://github.com/dotnet/runtime/blob/main/src/libraries/shims/netstandard/src/netstandard.csBeta Was this translation helpful? Give feedback.
All reactions