-
Notifications
You must be signed in to change notification settings - Fork 750
System.ArgumentException: Illegal characters in path #2376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is not a support forum. If you are using backslashes in strings in Python (and really, almost all programming languages) you have to either escape them or use a raw string literal.In Python that would be |
Sorry it was a typo. Yes, I have escaped the back slash. Its nothing to do with backslash. Because same code works fine when tested with python 3.7 and PythonNET 2.4.0. |
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 |
@manju1847 can you share your sys.path? I suspect we stumble on something funky there. |
echo %PATH% |
@manju1847 no, |
(client_env) C:\Automation\Main\drop_hal_pywinauto\TA_HAL>python --version (client_env) C:\Automation\Main\drop_hal_pywinauto\TA_HAL>where python (client_env) C:\Automation\Main\drop_hal_pywinauto\TA_HAL>python
|
The first line seems suspicious. There are quotes in directory name. These are impossible on Windows. |
You nailed it!!!! Yes, that is the root cause. After removing quotes from sys.path, AddReference is happy. Thanks a lot for helping to resolve this. |
Environment
Details
import clr
clr.AddReference("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.
The text was updated successfully, but these errors were encountered: