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

Json Serialization/Deserialization Issues #78

Open
tsk46th3gAva opened this issue Jan 31, 2022 · 2 comments
Open

Json Serialization/Deserialization Issues #78

tsk46th3gAva opened this issue Jan 31, 2022 · 2 comments

Comments

@tsk46th3gAva
Copy link

I'm having troubles with the code running on a Azure App Service, that revolves around Json Converters. It seems like the conversions are being converted in Sample project differently that in the SCIM foundation project. Has anyone else seen this behavior?

An unhandled exception was thrown by the application.System.InvalidCastException: Unable to cast object of type 'Newtonsoft.Json.Linq.JObject' to type 'System.Collections.Generic.Dictionary2[System.String,System.Object]'.at Microsoft.SCIM.TrustedJsonFactory.Create(String json) in C:\source\Microsoft.SystemForCrossDomainIdentityManagement\Schemas\TrustedJsonFactory.cs:line 14at Microsoft.SCIM.JsonFactory.Create(String json, Boolean acceptLargeObjects) in C:\source\Microsoft.SystemForCrossDomainIdentityManagement\Schemas\JsonFactory.cs:line 35at Microsoft.SCIM.JsonSerializer.ToJson() in C:\source\Microsoft.SystemForCrossDomainIdentityManagement\Schemas\JsonSerializer.cs:line 76at Microsoft.SCIM.Schematized.ToJson() in C:\source\Microsoft.SystemForCrossDomainIdentityManagement\Schemas\Schematized.cs:line 111at Microsoft.SCIM.Core2UserBase.ToJson() in C:\source\Microsoft.SystemForCrossDomainIdentityManagement\Schemas\Core2UserBase.cs:line 168at Microsoft.SCIM.Schematized.Serialize() in C:\source\Microsoft.SystemForCrossDomainIdentityManagement\Schemas\Schematized.cs:line 118at Microsoft.SCIM.Schematized.ToString() in C:\source\Microsoft.SystemForCrossDomainIdentityManagement\Schemas\Schematized.cs:line 126at System.Convert.ToString(Object value, IFormatProvider provider)at System.Convert.ToString(Object value)at Microsoft.AspNetCore.Mvc.MvcCoreLoggerExtensions.ActionMethodExecuting(ILogger logger, ControllerContext context, Object[] arguments)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()--- End of stack trace from previous location where exception was thrown ---at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT1.ProcessRequestAsync()

@danieltwigden
Copy link

I'm also facing this issue - same call-stack and exception. Did you manage to get anywhere with it or workaround it?

@tsk46th3gAva
Copy link
Author

tsk46th3gAva commented Mar 31, 2022

For me the NewtonSoft/Json mismatch occurred when I added Microsoft.Extensions.Logging.AzureAppServices nuget to my solution. The package enables to see Logging data via ILogger, within App services. I removed it from my solution and the serialization errors went away.

For the issues I was able to trace, it seem like DateTime values were serialized into JavaScript form,

I've tried multiple things, to try to get ILogger working.

  1. using different versions of Microsoft.Extensions.Logging.AzureAppServices, I tried from the latest 6.0.3 to 3.1.23.
  2. Updating the NewtonSoft packages through the Microsoft.SCIM project, this seem to break more things, then fix.
  3. Updated and try removed the Json.net packaged.

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