Referencing this Azure Tutorial, https://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-store-data-mongodb-vm/, released three months ago and already apparently out of date.
I followed the instructions, copied the code but am unable to build the application with this error: CS0246 the type or namespace MongoServer could not be found Dal.cs line 13.
Azure support responds "If a type or namespace is not available, it’s generally because of a missing assembly or DLL.". Agreed, but there is no missing assembly or dll. I suspect the API has changed but can find no documentation in support of this suspicion. I am therefore unable to resolve the issue.
I've included a screenshot showing the relevant assembly is installed.
I originally suspected the MongoDb.driver API had changed. The example uses version 2.0.1 and I had installed the latest, 2.2.4. However, after uninstalling the latest version and installing version 2.0.1 I get three errors, the original plus two others. I'm left wondering, how was this code originally built?
I learned through the MSDN Forums that I need to use the MongoDb.Driver.Legacy version, which can be installed through the Nuget Management Console with this command:
Install-Package mongocsharpdriver
The project now builds without error.
This is because you have installed an older version. Please go to Nuget Package console manager and reinstall the Mongocsharp Driver.
Install-Package mongocsharpdriver
After installing build the solution.
Just update the class to MongoClient
and it is solved :)
http://mongodb.github.io/mongo-csharp-driver/2.3/getting_started/quick_tour/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With