Closed teocomi closed 3 years ago
I got a weird error today doing some tests. Connecting my account to any Stream component in grasshopper, I get this: 1. Method not found: 'Void Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreIsSpecifiedMembers(Boolean)'.
Might be related? If so the reports are 3. Otherwise ignore me.
Yep, that's probably due to a Newtosoft conflict, try temporarily disabling your other GH plugins (eg jSwan...) We'll add this item to our backlog for the Beta release!
I tried to disable all plugins... same error.
If that helps, the conflict happen when getting the client Speckle.Core.Api.Client(account)
(source: https://discourse.mcneel.com/t/creating-brep-from-json/65873 and my pc)
Try see if this brings any joy: 295ea734e9a36ba37856263febe72fab61d15971
No joy.
Still getting the same.
when calling Speckle.Core.Api.Client(account)
GQLClient = new GraphQLHttpClient(
new GraphQLHttpClientOptions
{
EndPoint = new Uri(new Uri(account.serverInfo.url), "/graphql"),
UseWebSocketForQueriesAndMutations = false,
ConfigureWebSocketConnectionInitPayload = (opts) => { return new { Authorization = $"Bearer {account.token}" }; },
OnWebsocketConnected = OnWebSocketConnect,
},
new NewtonsoftJsonSerializer(),
HttpClient);
Can it be the extternal assembly GraphQL.Client.Serializer.Newtonsoft
?
Hey @iltabe can you please pull branch newtonsoft-alias
and try again?
Ah, I was writing here while you committed.
Test of today was to "delete" JSON dlls in Rhino/System folder. (rhino runs fine...)
Running in debug mode, I got still an error, which is not identified nor cached by the debugger.
Edit: I pull now and try again.
Urrà!
Thanks for the quick fix-support!
So I got to the bottom of it. The issue was caused by a combination of things:
When Rhino loads it sometimes ignore the N12 dependency and just loads N10, this causes problems in Speckle and in the GQL library. This is especially reproducible when enabling the "Memory load GHA using COFF byt array" setting, as that seems to make Rhino always ignore our N12 dependency.
Solution: The solution found so far consisted in:
Speckle.Newtonsoft.Json
package with updated namespaces, this was also published on NuGet (manually)Newtonsoft.Json
in favour of Speckle.Newtonsoft.Json
NewtonsoftJsonSerializer
class with a copy of the same also referencing Speckle.Newtonsoft.Json
Now Speckle can run alongside other GH plugin using earlier versions of Newtonsoft and as well it works well with the COFF setting enabled (see imga below).
Other solutions tried: I also tried aliasing the N12 nuget reference in use by Core but this didn't seem to completely fix the issue, probably because the namespaces of some methods used in N10 and N12 were still the same. This solution also didn't work out nice as the alias wasn't automatically propagated to the other Speckle projects referencig Core and was overall more problematic.
Will close this issue as soon as we approve the solution found.
Newtonsoft.Json is creating conflicts again, we had 2 reports of that happening in GH, so we should alias wherever is possible. Example of how to do so is in the DynamoConnector where we aliased an old version of Newtonsoft that Dynamo uses internally:
https://github.com/specklesystems/speckle-sharp/blob/master/ConnectorDynamo/ConnectorDynamo/ConnectorDynamo.csproj#L66-L69
https://github.com/specklesystems/speckle-sharp/blob/4fb9c8379b8d8a8da9ea2bd1a8f144b8d3e063c4/ConnectorDynamo/ConnectorDynamo/AccountsNode/Accounts.cs#L2