- Notifications
You must be signed in to change notification settings - Fork750
Description
Currently library fails on .NET 4.5. I know that 4.5 is not technically supported but the issue very painful because .NET 4.5 is update in place which overrides CLR. So, having it installed I don't really have an option to run it on ver 4.
When I try to run an application that uses Python for .NET i get exception
System.ArgumentNullException was unhandled
HResult=-2147467261
Message=Value cannot be null.
Parameter name: key
Source=mscorlib
ParamName=key
StackTrace:
at System.Collections.Generic.Dictionary2.FindEntry(TKey key) at System.Collections.Generic.Dictionary
2.TryGetValue(TKey key, TValue& value)
at Python.Runtime.GenericUtil.Register(Type t) in D:\Users\Barton\Documents\Visual Studio 2010\Projects\PySharp\trunk\pythonnet\src\runtime\genericutil.cs:line 41
at Python.Runtime.AssemblyManager.ScanAssembly(Assembly assembly) in D:\Users\Barton\Documents\Visual Studio 2010\Projects\PySharp\trunk\pythonnet\src\runtime\assemblymanager.cs:line 266
at Python.Runtime.AssemblyManager.Initialize() in D:\Users\Barton\Documents\Visual Studio 2010\Projects\PySharp\trunk\pythonnet\src\runtime\assemblymanager.cs:line 60
at Python.Runtime.Runtime.Initialize() in D:\Users\Barton\Documents\Visual Studio 2010\Projects\PySharp\trunk\pythonnet\src\runtime\runtime.cs:line 166
at Python.Runtime.PythonEngine.Initialize() in D:\Users\Barton\Documents\Visual Studio 2010\Projects\PySharp\trunk\pythonnet\src\runtime\pythonengine.cs:line 118
at Program.Program.main(String[] _arg1) in C:\Users\mitekm\Documents\Visual Studio 2013\Projects\TryPythonForNet\TryPythonForNet\Program.fs:line 54
InnerException:
I did some extra investigation. What happens is that this line of code fails
https://github.com/pythonnet/pythonnet/blob/develop/pythonnet/src/runtime/genericutil.cs#L41
because Namespace property is null on generic type EmptyArray`1 introduced in .NET 4.5. This type located in root namespace therefore Namespace property value is null.
I made quick fix on
https://github.com/pythonnet/pythonnet/blob/develop/pythonnet/src/runtime/assemblymanager.cs#L286
to replace
if (t.IsGenericTypeDefinition) {
GenericUtil.Register(t);
}
with
if (t.IsGenericTypeDefinition && t.IsPublic) {
GenericUtil.Register(t);
}
Honestly, I don't understand why the Python.Runtime process non-public type.
It worked on .NET 4 because this type EmptyArray'1 didn't exist there. As a matter of fact there were no generic types in root namespace.
Do you plan to start taking pull requests soon?
Thanks, Dmitry