Skip to content

Unable to start Debug Server: Constructor on type [...] not found #562

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

Closed
rjmholt opened this issue Apr 13, 2021 · 3 comments
Closed

Unable to start Debug Server: Constructor on type [...] not found #562

rjmholt opened this issue Apr 13, 2021 · 3 comments

Comments

@rjmholt
Copy link
Contributor

rjmholt commented Apr 13, 2021

Trying to get PowerShell Editor Services running with O# 0.19, we've been unable to start the debug server.

In our code, the failure seems to occur here.

It seems we're unable to process the initialize message from the debugger because the Activator can't create the PathFormat type:

[StringEnum]
public readonly partial struct PathFormat
{
public static PathFormat Path { get; } = new PathFormat("path");
public static PathFormat Uri { get; } = new PathFormat("uri");
}

Constructor on type 'System.Nullable`1[[OmniSharp.Extensions.DebugAdapter.Protocol.Models.PathFormat, OmniSharp.Extensions.DebugAdapter, Version=0.19.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]]' not found.
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) in /_/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs:line 3541
   at System.Activator.CreateInstance(Type type, Object[] args) in /_/src/libraries/System.Private.CoreLib/src/System/Activator.cs:line 31
   at OmniSharp.Extensions.JsonRpc.Serialization.Converters.EnumLikeStringConverter.ReadJson(JsonReader reader, Type objectType, IEnumLikeString existingValue, Boolean hasExistingValue, JsonSerializer serializer) in /_/src/JsonRpc/Serialization/Converters/EnumLikeStringConverter.cs:line 17
   at Newtonsoft.Json.JsonConverter1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in /_/Src/Newtonsoft.Json/JsonConverter.cs:line 126
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 2175
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 1064
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 2448
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 589
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 349
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) in /_/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:line 205
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) in /_/Src/Newtonsoft.Json/JsonSerializer.cs:line 916
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer) in /_/Src/Newtonsoft.Json/Linq/JToken.cs:line 2090
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase1.<RouteRequest>d__5.MoveNext() in /_/src/JsonRpc/RequestRouterBase.cs:line 102
@rjmholt
Copy link
Contributor Author

rjmholt commented Apr 13, 2021

Side note/question: how do we enable a logger for the RequestRouterBase? I notice this exception is logged there, but we don't have any loggers registered for it.

@andyleejordan
Copy link
Contributor

The OmniSharp v19 update changed this type when it was bumped to the latest DAP spec in #448

@rjmholt
Copy link
Contributor Author

rjmholt commented Apr 15, 2021

I've got a small repro of this btw:

internal class Program
{
    static void Main(string[] args)
    {
        object p = Activator.CreateInstance(typeof(PathFormat?), "uri");
        Console.WriteLine(p);
    }
}

Instead we have to recursively create the type:

internal class Program
{
    static void Main(string[] args)
    {
        string val = "uri";
        object p = Activator.CreateInstance(typeof(PathFormat?),
            val is null ? null : Activator.CreateInstance(typeof(PathFormat), "uri"));
        Console.WriteLine(p);
    }
}

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

Successfully merging a pull request may close this issue.

2 participants