Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Illegal characters in path#2377

manju1847 started this conversation inGeneral
Discussion options

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.

You must be logged in to vote

Replies: 4 comments

Comment options

I would try putting the file path through os.path.abspath().
Also i would try to put the dll in C:\ just to see if it works.

You must be logged in to vote
0 replies
Comment options

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.

You must be logged in to vote
0 replies
Comment options

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
assembly = Assembly.LoadFrom(path)

You must be logged in to vote
0 replies
Comment options

This is resolved. This issue is because of bad sys.path. Details can be found in#2376

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
General
Labels
None yet
2 participants
@manju1847@feketeimre

[8]ページ先頭

©2009-2025 Movatter.jp