-
Notifications
You must be signed in to change notification settings - Fork 768
Description
Environment
- Pythonnet version: 3.0.1
- Python version:3.9.2
- Operating System: Windows 10
- .NET Runtime: .Net 6
Details
We have some issues when load some asseblies which is built based on .net6 and some depedencies to system** binaries like "System.Drawing.Common".
Tried to add the dependecy path into %PATH%, not working:
Unhandled exception. System.BadImageFormatException: Could not load file or assembly 'System.Drawing.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (0x80131058)
And found the same issue to run demo\helloform.py if set PYTHONNET_RUNTIME=coreclr
- What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
- set PYTHONNET_RUNTIME=coreclr
- python D:\pythonnet-master\demo\helloform.py
Traceback (most recent call last):
File "D:\pythonnet-master\demo\helloform.py", line 6, in
clr.AddReference("System.Windows.Forms")
System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows.Forms, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'System.Windows.Forms, Culture=neutral, PublicKeyToken=null'
at System.Reflection.RuntimeAssembly.InternalLoad(ObjectHandleOnStack assemblyName, ObjectHandleOnStack requestingAssembly, StackCrawlMarkHandle stackMark, Boolean throwOnFileNotFound, ObjectHandleOnStack assemblyLoadContext, ObjectHandleOnStack retAssembly)
at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, RuntimeAssembly requestingAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Python.Runtime.AssemblyManager.LoadAssembly(AssemblyName name) in /tmp/build-via-sdist-dq4gmg3h/pythonnet-3.0.1/src/runtime/AssemblyManager.cs:line 227
at Python.Runtime.CLRModule.AddReference(String name) in /tmp/build-via-sdist-dq4gmg3h/pythonnet-3.0.1/src/runtime/Types/ClrModule.cs:line 107