[CSHARP-2276] IMongoIndexManager CreateOne or CreateOneAsync methods can throw NullReferenceException Created: 20/May/18 Updated: 28/Oct/23 Resolved: 23/May/18 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 2.7.0 |
| Fix Version/s: | 2.7.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Mohammed Abdel Gader Ibrahim ElAmin [X] | Assignee: | Robert Stam |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 10 64-bit, MongoDB 3.7.9, .NET Core 2.1 RC 1 |
||
| Description |
|
Calling the IMongoIndexManager CreateOne or CreateOneAsync methods and omitting the options argument (or passing null for it) result in a NullReferenceException. *+Original description+:* I am using the C# driver 2.7.0-beta0001 and MongoDB 3.7.9 server and I am trying to create multiple indexes on a standalone server using the new transaction feature and I always get an exception:
Here is my code:
Even if I didn't use the transactions by removing the session variable, I also get the same exception. If I used the old deprecated method like in this code I get a different exception:
Here is the other exception:
|
| Comments |
| Comment by Githook User [ 23/May/18 ] | |||
|
Author: {'username': 'rstam', 'name': 'rstam', 'email': 'robert@robertstam.org'}Message: | |||
| Comment by Robert Stam [ 22/May/18 ] | |||
|
Additional note: I don't think create index (single or multiple) can be run inside a transaction.
| |||
| Comment by Robert Stam [ 22/May/18 ] | |||
|
Just noticed in your original description that you mention you are testing against a standalone. Standalones do not support transactions. If you want to test transactions you can use a single member replica set. Also, not everything transaction related works yet in server 3.7.9. You might possibly need to test against a newer version of the server. | |||
| Comment by Robert Stam [ 22/May/18 ] | |||
|
I can reproduce this. The issue is related to the options parameter of CreateOneAsync being omitted (which results in the default value of null). You can work around this by replacing:
with:
As for the other exception, transactions are currently only supported on replica sets. What deployment type are you testing against?
|