Replies: 4 comments
-
I would try putting the file path through os.path.abspath(). |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for reply. But no luck. Tried with os.path.abspath() and also directly from C: just to reduce the path length. Still I see the same "Illegal characters in path" error. One more point is, same code is working fine when tested from Visual studio 2022 environment. But when executed from windows command line I get into this wired issue. Not sure how Visual studio environment is making the difference. |
Beta Was this translation helpful? Give feedback.
-
Tried to load the same DLL using Assembly.LoadFrom(path) - this works without any issues. But clr.AddReference(path) throws Illegal characters in path exception. from System.Reflection import Assembly |
Beta Was this translation helpful? Give feedback.
-
This is resolved. This issue is because of bad sys.path. Details can be found in #2376 |
Beta Was this translation helpful? Give feedback.
-
Environment
Pythonnet version: 3.0.3
Python version: 3.10.11
Operating System: Windows 10
.NET Runtime: 4.5
Details
Trying to load DLL using AddReference.
import clr
clr.AddReference(r"C:\MyProject\TestFolder\_Dependencies\MyDLLProject\Test.TA.MyVersion.Test.dll")
System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
at System.IO.Path.Combine(String path1, String path2)
at Python.Runtime.AssemblyManager.d__15.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at Python.Runtime.AssemblyManager.LoadAssemblyPath(String name)
at Python.Runtime.CLRModule.AddReference(String name)
DLL is not a new implementation. Same DLL and same path was working fine with python 3.7 and PythonNET 2.4.0. This issue started happening when we upgraded python and Pythonnet versions.
Anyone faced such similar issue? Not sure if I am missing something. Appreciate if someone sharing thoughts.
Beta Was this translation helpful? Give feedback.
All reactions