Skip to content

Commit 22a24a4

Browse files
committed
First try on loading the correct 'DLL' on .NET Core
1 parent 41577fc commit 22a24a4

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

Python.Runtime/pythonengine.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Reflection;
88
using System.Runtime.InteropServices;
99
using Python.Runtime.Native;
10+
using Python.Runtime.Interfaces;
1011

1112
namespace Python.Runtime
1213
{
@@ -118,11 +119,6 @@ public static string BuildInfo
118119
get { return Marshal.PtrToStringAnsi(Runtime.Py_GetBuildInfo()); }
119120
}
120121

121-
public static string Platform
122-
{
123-
get { return Marshal.PtrToStringAnsi(Runtime.Py_GetPlatform()); }
124-
}
125-
126122
public static string Copyright
127123
{
128124
get { return Marshal.PtrToStringAnsi(Runtime.Py_GetCopyright()); }
@@ -263,10 +259,12 @@ public static int InternalInitialize(IntPtr data, int size)
263259

264260
try
265261
{
266-
// Console.WriteLine("Before Initialize");
267-
// Console.Out.Flush();
262+
Console.WriteLine("Running on {0}", RuntimeInformation.FrameworkDescription);
263+
264+
var ass = Platform.InternalLoadContext.Instance.LoadFromAssemblyName(new AssemblyName("Python.Runtime.Native"));
268265

269-
// Python.Runtime.Platform.InternalLoadContext.Instance.EnterContextualReflection();
266+
var typ = ass.GetType("Python.Runtime.Native.LibPythonPInvoke");
267+
Runtime.LibPython = (ILibPython)Activator.CreateInstance(typ);
270268

271269
Initialize(setSysArgv: false);
272270

@@ -316,8 +314,8 @@ public static int InternalInitialize(IntPtr data, int size)
316314
}
317315
catch (Exception e)
318316
{
319-
// Console.Error.WriteLine(e.ToString());
320-
// Console.Error.Write(e.StackTrace);
317+
Console.Error.WriteLine(e.ToString());
318+
Console.Error.Write(e.StackTrace);
321319
return -2;
322320
}
323321
}

Python.Runtime/runtime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,6 @@ internal static void SetNoSiteFlag()
856856
SetPyNoSiteFlag(1);
857857
}
858858

859-
static Interfaces.ILibPython LibPython;
859+
internal static Interfaces.ILibPython LibPython;
860860
}
861861
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy