This project has moved and is read-only. For the latest updates, please go here.


Issue with Destablisation of the runtime.


Not sure what is up but if you debug and hit this section it tries to return twice... I commeneted out the conditional and the returns worked as per normal. May have hit a complier bug.
protected virtual IValueProvider CreateMemberValueProvider(MemberInfo member)
//#if !PocketPC && !SILVERLIGHT
  if (DynamicCodeGeneration)
    return new DynamicValueProvider(member);
  return new ReflectionValueProvider(member);
Closed Jun 28, 2011 at 7:08 AM by JamesNK


Kwal wrote Jun 23, 2011 at 4:15 PM

This is the same code that I believe is causing issues for me while trying to utilize Json.NET within an Azure worker role. Below is the associated stack trace:

System.Security.VerificationException: Operation could destabilize the runtime.
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateMemberValueProvider(MemberInfo member)
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperties(Type type, MemberSerialization memberSerialization)
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType)
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)
at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IWrappedCollection values, JsonArrayContract contract, JsonProperty member, JsonContract collectionValueContract)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContract collectionValueContract)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value)
at Newtonsoft.Json.JsonSerializer.Serialize(JsonWriter jsonWriter, Object value)
at Raven.Json.Linq.RavenJToken.FromObjectInternal(Object o, JsonSerializer jsonSerializer)
at Raven.Json.Linq.RavenJToken.FromObject(Object o, JsonSerializer jsonSerializer)
at Raven.Http.Extensions.HttpExtensions.WriteJson(IHttpContext context, Object obj)
at Raven.Database.Server.Responders.DocumentBatch.Batch(IHttpContext context)
at Raven.Database.Server.Responders.DocumentBatch.Respond(IHttpContext context)
at Raven.Http.HttpServer.DispatchRequest(IHttpContext ctx)
at Raven.Http.HttpServer.HandleActualRequest(IHttpContext ctx)

JamesNK wrote Jun 25, 2011 at 2:52 AM

Which version of Json.NET are you using and which dll? Could you also include the class you are trying to serialize.

Kwal wrote Jun 27, 2011 at 5:27 AM

As it turns out, the issue was caused by enabling IntelliTrace while running the worker role. Looking into it a bit further, IntelliTrace is causing this type of error to occur due to the dynamic IL it injects into the code which was is, in the case of Json.NET, causing overall bad IL, this the exception.

Kwal wrote Jun 27, 2011 at 5:29 AM grammar and editing skills were quite bad in the last comment - my apologies =)

wrote Jun 28, 2011 at 7:08 AM

AcidPAT wrote Jul 6, 2011 at 9:25 AM

Can you clarify please in which release this is fixed? I am using 4.0.2 and seeing the same issue with Intellitrace Enabled (in an Azure web role)
@ Kwal - did you need to deploy a private build of JSon from sources?

simnova wrote Nov 21, 2011 at 7:28 AM

I am using v4.0.30319 and am also seeing the same issue with Intellitrace Enabled (in an Azure web role).

Will there be a version where this issue is resolved?

simnova wrote Nov 21, 2011 at 7:33 AM

Added ticket : as this is an Intellitrace issue and may have been closed out without proper details.

havnfn wrote Jun 1, 2012 at 9:39 PM

Disabling Intellitrace in VS 2012 RC fixed the issue for me. Thanks for the tip above.

wrote Feb 22, 2013 at 2:48 AM

wrote May 16, 2013 at 1:37 PM