Cannot modify frozen collection error in RavenDB 3.0.3800

32 views
Skip to first unread message

Randall Borck

unread,
Nov 25, 2015, 12:53:49 PM11/25/15
to RavenDB - 2nd generation document database
I'm trying to upgrade RavenDB from 2.5.2935 to 3.0.3800 and am getting this exception when trying to load our settings document `settings/1` from a database:

Logging to:c:\grc\platform\QueueHost\bin\Debug\Logs\QueueHost-console.log

Unhandled Exception: System.InvalidOperationException: Cannot modify a frozen collection.
   at Raven.Imports.Newtonsoft.Json.JsonConverterCollection.InsertItem(Int32 index, JsonConverter item) in c:\Builds\RavenDB-Stable-3.0\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonConverterCollection.cs:line 80
   at System.Collections.ObjectModel.Collection`1.Add(T item)
   at TNW.Core.Configuration.Serializer.ServerToServerSerializerBuilder(Action`1 configureConventions, Action`1 configureSerializer) in c:\grc\core\TNW.Core\Configuration\Serializer.cs:line 38
   at TNW.Core.Configuration.Serializer.get_ServerToServerInstance() in c:\grc\core\TNW.Core\Configuration\Serializer.cs:line 29
   at TNW.Core.Configuration.RavenConfigLoader.Load[T](String fullDocumentId) in c:\grc\core\TNW.Core\Configuration\ConfigLoader.cs:line 40
   at TNW.Core.Configuration.RavenConfigLoader.LoadSettings() in c:\grc\core\TNW.Core\Configuration\ConfigLoader.cs:line 22
   at TNW.QueueHost.Program.Main(String[] args) in c:\grc\platform\QueueHost\Program.cs:line 113


The document loads fine when loaded from the web url, but when our queue spins up to get the configurations, I get the above exception. Any insight would be appreciated.

Thanks,
Randall

Randall Borck

unread,
Nov 25, 2015, 12:54:36 PM11/25/15
to RavenDB - 2nd generation document database
Oh, and I forgot to mention, I found this post, but there was no information about what's going on or how to resolve it: https://groups.google.com/forum/#!topic/ravendb/DbTpK2Rxj0s

Oren Eini (Ayende Rahien)

unread,
Nov 26, 2015, 2:27:15 AM11/26/15
to ravendb
did you modify the json serializer in some manner (CustomizeJsonSerializer)?

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Randall Borck

unread,
Dec 1, 2015, 4:43:11 PM12/1/15
to RavenDB - 2nd generation document database
Yes. We use a message converter, which is apparently what is throwing the error. The code I am looking at is here:

```
    private static JsonSerializer ServerToServerSerializerBuilder(Action<DocumentConvention> configureConventions = null, Action<JsonSerializer> configureSerializer = null) {
      var documentConvention = new DocumentConvention();
      documentConvention.IdentityTypeConvertors.Add(new NullableGuidConverter());
      if (null != configureConventions) configureConventions(documentConvention);

      var jsonSerializer = documentConvention.CreateSerializer();
      jsonSerializer.Converters.Add(ObjectFactory.GetInstance<MessageConverter>());

      if (null != configureSerializer) configureSerializer(jsonSerializer);
      return jsonSerializer;
    }
```

It calls the constructor just fine, but then throws the error after the constructor returns. Any other insight?

Thanks,
Randall

Randall Borck

unread,
Dec 1, 2015, 5:02:05 PM12/1/15
to RavenDB - 2nd generation document database
Ok, never mind, that was it. I rebuilt the collection and assigned it instead of trying to add a new converter. My new code is as follows (in case someone else runs into this and finds my post):

```
      var documentConvention = new DocumentConvention();
      documentConvention.IdentityTypeConvertors.Add(new NullableGuidConverter());
      configureConventions?.Invoke(documentConvention);

      var jsonSerializer = documentConvention.CreateSerializer();
      var messageConverter = ObjectFactory.GetInstance<MessageConverter>();
      var converters = new List<JsonConverter>(jsonSerializer.Converters) {messageConverter};
      jsonSerializer.Converters = new JsonConverterCollection(converters);

      configureSerializer?.Invoke(jsonSerializer);
      return jsonSerializer;
```
Reply all
Reply to author
Forward
0 new messages