RavenDB4 'documentStore.Operations' threw an exception of type 'System.ArgumentNullException'

31 views
Skip to first unread message

oru malayali

unread,
Mar 20, 2018, 5:53:09 PM3/20/18
to RavenDB - 2nd generation document database
Hi,
After the document store is created and initialized,
the documentStore.Operations property shows the following in watch window:
'documentStore.Operations' threw an exception of type 'System.ArgumentNullException'.

Below is how I create the document store:
            var documentStore = new DocumentStore
            {
                Urls = new[] { connectionStr },
                Conventions =
                {
                    SaveEnumsAsIntegers = true,
                    FindCollectionName = type =>
                        typeof(ChangeProposal).IsAssignableFrom(type)
                            ? "ChangeProposals"
                            : typeof(PropertyDefinition).IsAssignableFrom(type)
                                ? "PropertyDefinitions"
                                : DocumentConventions.DefaultGetCollectionName(type)
                }
            };

Is there something wrong or missing in how I create it?
The version I am using is 4.0.3-patch-40031.

Thanks,
Lokesh

Oren Eini (Ayende Rahien)

unread,
Mar 21, 2018, 3:01:43 AM3/21/18
to ravendb
You are missing the Database property.
The NRE (in favor of an explicit error) has already been corrected in the latest code.

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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tal Weiss

unread,
Mar 21, 2018, 8:17:29 AM3/21/18
to RavenDB - 2nd generation document database
Also you need to call Initialize()
--

Hibernating Rhinos Ltd  cid:image001.png@01CF95E2.8ED1B7D0

Tal Weiss l Core Team Developer Mobile:+972-54-802-4849

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

RavenDB paving the way to "Data Made Simplehttp://ravendb.net/ 

oru malayali

unread,
Mar 21, 2018, 9:17:09 AM3/21/18
to rav...@googlegroups.com
Hi 
Oren,
Is it compulsory to set the Database property when I create the document store? I will update the packages and try again.
Thanks.

Tal,
I am calling the Initialize, I missed that line of code here. Thanks.

Lokesh.

--
You received this message because you are subscribed to a topic in the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/HG2MF-Vs0Oo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ravendb+unsubscribe@googlegroups.com.

oru malayali

unread,
Mar 21, 2018, 10:10:17 AM3/21/18
to rav...@googlegroups.com
Hi Oren,
I got an ArgumentNullException when doing the following:
    session.Advanced.DocumentStore.Operations.ForDatabase(databaseName).Send(operation);
That is when the Database name is not set when creating the document store.

The following is the stacktrace:
   at System.Collections.Concurrent.ConcurrentDictionary`2.TryGetValue(TKey key, TValue& value)
   at Raven.Client.Documents.DocumentStore.GetRequestExecutor(String database)
   at Raven.Client.Documents.DocumentStore.OpenSession(SessionOptions options)
   at Raven.Client.Documents.DocumentStore.OpenSession()
   at Raven.Client.Documents.Operations.DeleteByQueryOperation`1.GetCommand(IDocumentStore store, DocumentConventions conventions, JsonOperationContext context, HttpCache cache)
   at Raven.Client.Documents.Operations.OperationExecutor.<SendAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Raven.Client.Util.AsyncHelpers.<>c__DisplayClass3_1`1.<<RunSync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Raven.Client.Util.AsyncHelpers.RunSync[T](Func`1 task)
   at Raven.Client.Documents.Operations.OperationExecutor.Send(IOperation`1 operation, SessionInfo sessionInfo)

And when I set the Database to string.Empty, it works fine.
Btw, the operation is a DeleteByQueryOperation.

So, I guess the Database name cannot be null?! 

Thanks.

Oren Eini (Ayende Rahien)

unread,
Mar 21, 2018, 10:39:20 AM3/21/18
to ravendb
The database name _can_ be null (that was a bug that was recently fixed) 
But if it is, you'll need to specify which db in every call

oru malayali

unread,
Mar 21, 2018, 10:55:37 AM3/21/18
to rav...@googlegroups.com
I see. I am using the 4.0.3-patch-40033 version. 
Also, I am using the Operation.ForDatabase as you recommended before, when I have an operation to do, so that I am sure. 
I will wait for the next prerelease if the fix is in the Nightly.

Thanks a lot.

Reply all
Reply to author
Forward
0 new messages