You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have just starting using Siaqodbcloud service to sync data to mongodb. Currently running the SyncExample (invoices) with the SiaqoCloud-Service web app. I have configured everything as in the readme. To reproduce this, first run mongod service, then start the web app, then start the SyncExamples console app. The following error is displayed on the SyncExamples console:
Error downloading changes:The remote server returned an error: (500) Internal Server Error.
And the following debug output is displayed from the server side:
A first chance exception of type 'System.NullReferenceException' occurred in SiaqodbCloudService.dll
A first chance exception of type 'System.NullReferenceException' occurred in mscorlib.dll
After investigating, the source of the problem was found to be in the MongoDB Mapper.cs file:
foreach (string tagName in cobj.Tags.Keys) { doc[tagName] = BsonTypeMapper.MapToBsonValue(cobj.Tags[tagName]); }
This was throwing a NullReferenceException because the Tags in cobj where not initialised from the SyncExamples side. My understanding is that tags don't have to be used, but are useful from the developer's point view.
My solution was to first check that the tags were not null before doing the foreach loop:
if (cobj.Tags != null) { foreach (string tagName in cobj.Tags.Keys) { doc[tagName] = BsonTypeMapper.MapToBsonValue(cobj.Tags[tagName]); } }
After building and running, the following is displayed from the console:
I have just starting using Siaqodbcloud service to sync data to mongodb. Currently running the SyncExample (invoices) with the SiaqoCloud-Service web app. I have configured everything as in the readme. To reproduce this, first run mongod service, then start the web app, then start the SyncExamples console app. The following error is displayed on the SyncExamples console:
Error downloading changes:The remote server returned an error: (500) Internal Server Error.
And the following debug output is displayed from the server side:
A first chance exception of type 'System.NullReferenceException' occurred in SiaqodbCloudService.dll
A first chance exception of type 'System.NullReferenceException' occurred in mscorlib.dll
After investigating, the source of the problem was found to be in the MongoDB Mapper.cs file:
foreach (string tagName in cobj.Tags.Keys) { doc[tagName] = BsonTypeMapper.MapToBsonValue(cobj.Tags[tagName]); }
This was throwing a NullReferenceException because the Tags in cobj where not initialised from the SyncExamples side. My understanding is that tags don't have to be used, but are useful from the developer's point view.
My solution was to first check that the tags were not null before doing the foreach loop:
if (cobj.Tags != null) { foreach (string tagName in cobj.Tags.Keys) { doc[tagName] = BsonTypeMapper.MapToBsonValue(cobj.Tags[tagName]); } }
After building and running, the following is displayed from the console:
Sync finished!
Uploaded:2 documents!
Downloaded:0 documents!
If this is the correct handling of this error, could you please fix??
Thanks!
The text was updated successfully, but these errors were encountered: