Skip to content
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

csharp-ls: could not OpenProjectAsync #46

Closed
nikolightsaber opened this issue Sep 1, 2022 · 12 comments
Closed

csharp-ls: could not OpenProjectAsync #46

nikolightsaber opened this issue Sep 1, 2022 · 12 comments

Comments

@nikolightsaber
Copy link

nikolightsaber commented Sep 1, 2022

I use neovim with csharp-ls and it suddenly stopped working. I really don't understand why.

Every time I startup the lsp I get an error on startup.

LSP[csharp_ls][Info] csharp-ls: initializing, csharp-ls version 0.4.0.0; options are: {
  "logLevel": 4
}
LSP[csharp_ls][Info] csharp-ls: csharp-ls is released under MIT license and is not affiliated with Microsoft Corp.; see https://github.com/razzmatazz/csharp-language-server
LSP[csharp_ls][Log] csharp-ls: attempting to find and load solution based on cwd: "/home/nikolai/repos/astar_maze"..
LSP[csharp_ls][Log] csharp-ls: looking for .csproj/fsproj files on /home/nikolai/repos/astar_maze..
LSP[csharp_ls][Log] csharp-ls: 0 solution(s) found: []
LSP[csharp_ls][Log] csharp-ls: no or multiple .sln files found on /home/nikolai/repos/astar_maze
LSP[csharp_ls][Log] csharp-ls: loading proj file /home/nikolai/repos/astar_maze/AStarMaze.csproj..
LSP[csharp_ls][Log] csharp-ls: could not OpenProjectAsync('/home/nikolai/repos/astar_maze/AStarMaze.csproj'): System.AggregateException: One or more errors occurred. (Could not load file or assembly 'System.Conf
iguration.ConfigurationManager, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Could not find or load a specific file. (0x80131621))
 ---> System.IO.FileLoadException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Could not find or load a specifi
c file. (0x80131621)
File name: 'System.Configuration.ConfigurationManager, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
 ---> System.IO.FileLoadException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Microsoft.Build.Locator.MSBuildLocator.<>c__DisplayClass15_0.<RegisterMSBuildPath>g__TryLoadAssembly|3(AssemblyName assemblyName)
   at Microsoft.Build.Locator.MSBuildLocator.<>c__DisplayClass15_0.<RegisterMSBuildPath>b__2(AssemblyLoadContext _, AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
   at Microsoft.Build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2 toolsets, ToolsetConfigurationReader configurationReader, PropertyDictionary`1 environmentProperties, PropertyDictionary`1 globalProper
ties, ToolsetDefinitionLocations locations)
   at Microsoft.Build.Evaluation.ProjectCollection.InitializeToolsetCollection(ToolsetConfigurationReader configReader)
   at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCo
unt, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly, Boolean useAsynchronousLogging)
   at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties)
   at Microsoft.CodeAnalysis.MSBuild.Build.ProjectBuildManager.StartBatchBuild(IDictionary`2 globalProperties)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.LoadAsync(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.LoadProjectInfoAsync(String projectFilePath, ProjectMap projectMap, IProgress`1 progress, ILogger msbuildLogger, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.OpenProjectAsync(String projectFilePath, ILogger msbuildLogger, IProgress`1 progress, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
LSP[csharp_ls][Log] csharp-ls: OK, 1 project files loaded

Non of the lsp commands work

I found emacs-lsp/lsp-mode#3198 and #3

But I feel the issue should be fixed after those issues

I am on the latest version of csharp-ls

I am on the correct version of dotnet (6) Like I said it suddenly stopped working (I probably did a sudo apt upgrade)

I feel like I am missing something obvious but I cannot seem to find the issue here

@nikolightsaber
Copy link
Author

nikolightsaber commented Sep 1, 2022

I build this project from source linked it to neovim lsp and it seems to have fixed it I think it is the fix in #45

Would it be possible to make a tag ?

@razzmatazz
Copy link
Owner

razzmatazz commented Sep 2, 2022

I started getting the same thing just recently (a couple of days agao), on macOS though

this looks to me like SDK breakage or something to me:

the cause (probably) is this:

do you have .net 7 previews installed by chance? like I do..

@razzmatazz
Copy link
Owner

razzmatazz commented Sep 2, 2022

also, I am not sure if #45 fixes it, because now I'm getting this:

LSP :: csharp-ls: msbuildWorkspace.Diagnostics: [Failure] Msbuild failed when processing the file '/Users/bob/src/test-csharp/project2/project2.csproj' with message: The SDK 'Microsoft.NET.Sdk' specified could not be found.  /Users/bob/src/test-csharp/project2/project2.csproj
LSP :: csharp-ls: msbuildWorkspace.Diagnostics: [Failure] Msbuild failed when processing the file '/Users/bob/src/test-csharp/project1/project1.csproj' with message: The SDK 'Microsoft.NET.Sdk' specified could not be found.  /Users/bob/src/test-csharp/project1/project1.csproj

for my test solution, and none of the projects load properly

@razzmatazz
Copy link
Owner

I also see more related issues here:

some people say the cause is:

UPDATE:

  • ok, I think I fixed the issue with 59e00b4

you need to build csharp-ls from source or wait a bit until I release a new version

@nikolightsaber
Copy link
Author

Hi thanks for the fast response !

This confirms my feeling it was tied to a sudo apt upgrade and dotnet versions.

For your info I don't have dotnet 7 previews installed. I'm on a simple ubunu 20.04.

I will build form source for.

@nikolightsaber
Copy link
Author

I compiled from source again and it seems to work fine.

Might I suggest a build from source section in the README I used:

dotnet build, but with that you need all the dll's

For one package I used:

dotnet publish -r linux-x64 -p:PublishSingleFile=true -p:UseAppHost=true --self-contained false

This project works really good as an LSP for me. For work we have a huge project with the whole range of Microsoft Targets,
From NET 5.0 to .NET standard 2.0 to windows only .NET Framework 4.6.1. Almost all LSP actions across projects work and inside a single file everything always works in Linux with neovim.

Thanks again for the help 😄

@razzmatazz
Copy link
Owner

great to hear!

could you make a PR though? I am not sure what changes you are proposing, and maybe you could write a PR with the changes proposed yourself?

will close this issue once I have new version released

@razzmatazz
Copy link
Owner

@nikolightsaber just a slight off-topic question–do you use razor? I am thinking of developing support for cshtml, but not sure if that is very much a popular request

@nikolightsaber
Copy link
Author

Good idea I will make a PR.

No I don't use razor at the moment. I also have no idea how much it is used. I hear it is pretty cool though.

@razzmatazz
Copy link
Owner

I have released a new version on nuget which should fix this issue:

@nikolightsaber
Copy link
Author

Confirm it working for me with 0.5.6 you can close the issue for me

Thanks again,

@razzmatazz
Copy link
Owner

great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants