0

I am trying to open a C# solution file with

    Solution solutionToAnalyze = buildWorkspace.OpenSolutionAsync(pathSolution).Result;

and I get the message that I have illegal characters in the path.

If I write the path to the Console, it shows

C:\AppsDemo\CSharp\Duplicates\Duplicates.sln

and I cannot see any illegal characters. It looks perfectly fine to me.

The complete debug information is this:

    This exception was originally thrown at this call stack:
    System.IO.Path.LegacyNormalizePath(string, bool, int, bool)
    System.IO.Path.NormalizePath(string, bool, int, bool)
    System.IO.Path.GetFullPathInternal(string)
    Microsoft.CodeAnalysis.MSBuild.ProjectFile.GetAbsolutePath(string)
    Microsoft.CodeAnalysis.MSBuild.ProjectFile.GetOutputDirectory()
    Microsoft.CodeAnalysis.CSharp.CSharpProjectFileLoader.CSharpProjectFile.CSharpCompilerInputs.CSharpCompilerInputs(Microsoft.CodeAnalysis.CSharp.CSharpProjectFileLoader.CSharpProjectFile)
    Microsoft.CodeAnalysis.CSharp.CSharpProjectFileLoader.CSharpProjectFile.GetProjectFileInfoAsync(System.Threading.CancellationToken)
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
    System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task)
    ...
    [Call Stack Truncated]
Inner Exception 1:
ArgumentException: Illegal characters in path.

Unfortunatelly the methods on which this crashes are internal and I cannot intervene or see what cause the error.

What am I doing wrong?

1 Answers1

0

Have u tried putting an "@" in front of the path? like this: @"C:\AppsDemo\CSharp\Duplicates\Duplicates.sln" so u dont mess up your path with your "\".

5Wagga
  • 1
  • 2
  • Unfortunately (1) the string it is not hard coded but comes from another part of the application, and (2) even if it temporarily replace it with a hardcoded value, I cannot see what would be wrong with this string containing a path. It is perfectly legal. In any case, I suspect that the problem comes from some incompatibility between versions of various packages I am using. I plan to research more and post a solution, if I find one. – Michael Oara Feb 05 '20 at 16:18