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

Exception "No method by the name 'initialize' is found." #1318

Open
hahoyer opened this issue Aug 13, 2024 · 0 comments
Open

Exception "No method by the name 'initialize' is found." #1318

hahoyer opened this issue Aug 13, 2024 · 0 comments

Comments

@hahoyer
Copy link

hahoyer commented Aug 13, 2024

When starting my languageserver from my extension I get an exception from "VS/IDE/TaskStatusCenter/RunningRegisteredTaskFailed":

            StreamJsonRpc.RemoteMethodNotFoundException: No method by the name 'initialize' is found.
            at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__154`1.MoveNext()
            --- End of stack trace from previous location where exception was thrown ---
            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            at Microsoft.VisualStudio.LanguageServer.Client.JsonRpcExtensionMethods.<SendMethodRequestWithTelemetryAsync>d__0`2.MoveNext()
            --- End of stack trace from previous location where exception was thrown ---
            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            at Microsoft.VisualStudio.LanguageServer.Client.RemoteLanguageClientInstance.<SendInitializeRequestAsync>d__115.MoveNext()
            --- End of stack trace from previous location where exception was thrown ---
            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            at Microsoft.VisualStudio.LanguageServer.Client.RemoteLanguageClientInstance.<InitializeAsync>d__110.MoveNext()
            --- End of stack trace from previous location where exception was thrown ---
            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            at Microsoft.VisualStudio.Threading.TplExtensions.<WithTimeout>d__5.MoveNext()
            --- End of stack trace from previous location where exception was thrown ---
            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            at Microsoft.VisualStudio.LanguageServer.Client.RemoteLanguageClientInstance.<TrackTaskAsync>d__113.MoveNext()
            --- End of stack trace from previous location where exception was thrown ---
            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            at Microsoft.VisualStudio.LanguageServer.Client.RemoteLanguageClientInstance.<ActivateLanguageClientAsync>d__122.MoveNext()

What does this message mean? For which class is the "initialize" method missing?

I use

  • omnisharp.extensions.languageserver 0.19.9
  • Visual Studio Extensibility Sdk and Visual Studio Extensibility Framework 17.10.2084
  • VS2022
  • Nerdbank-Streams (as suggested)

Here is my language-server-provider:

using System.Diagnostics;
using System.IO.Pipelines;
using JetBrains.Annotations;
using Microsoft.VisualStudio.Extensibility;
using Microsoft.VisualStudio.Extensibility.LanguageServer;
using Microsoft.VisualStudio.RpcContracts.LanguageServerProvider;
using Nerdbank.Streams;
using ReniLSP;

namespace Reni.LSPVSIX;

#pragma warning disable VSEXTPREVIEW_LSP
[VisualStudioContribution]
[UsedImplicitly]
public sealed class ReniLanguageServerProvider : LanguageServerProvider
{
	[UsedImplicitly]
	Task? ServerPipeTask;

	public ReniLanguageServerProvider
		(ExtensionCore container, VisualStudioExtensibility extensibilityObject, TraceSource traceSource)
		: base(container, extensibilityObject) { }

	public override LanguageServerProviderConfiguration LanguageServerProviderConfiguration =>
		new("Reni Language Server",
			new[]
			{
				DocumentFilter.FromDocumentType(Constants.LanguageName),
			});

	// Activate the language server and return a duplex pipe that communicates with the server. 
	public override Task<IDuplexPipe?> CreateServerConnectionAsync(CancellationToken token)
	{
		var (pipeToServer, pipeToVS) = FullDuplexStream.CreatePair();

		ServerPipeTask = Task.Run(
			() => MainContainer.RunServer(pipeToVS.UsePipeReader(), pipeToServer.UsePipeWriter())
			, token
		);

		return Task.FromResult<IDuplexPipe?>(new DuplexPipe(pipeToServer.UsePipeReader(), pipeToVS.UsePipeWriter()));
	}

	protected override void Dispose(bool isDisposing)
	{
		if(isDisposing)
			ServerPipeTask?.Dispose();
		base.Dispose(isDisposing);
	}

	public override Task OnServerInitializationResultAsync
	(
		ServerInitializationResult startState, LanguageServerInitializationFailureInfo? initializationFailureInfo
		, CancellationToken cancellationToken
	) =>
		// Method called when server activation was completed successfully or failed, denoted by "startState".
		Task.CompletedTask;
}
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

1 participant