Referencing this Azure Cosmos Db Tutorial ( https://docs.microsoft.com/en-us/azure/cosmos-db/create-mongodb-dotnet ), released three months ago and apparently already out of date.
I followed the instructions: cloned the sample app files, updated my connection string, installed the MongoDB.Driver through the Nuget package manager and ran the app. The build (in Visual Studio 2017) failed due to several CS0246 & CS0234 errors in 2 of the app files. See screenshot
I'm not a C# developer. I suspect either the MongoDB API has changed or the MongoDB.Driver is out of date. The error implies a directive or assembly reference is missing.
Either way, this is an issue in the underlying app files which were written by Microsoft and not me. See screenshot here. Does anyone have any recommendations on how I can troubleshoot these errors and successfully run the app? Maybe I need to install an older legacy version of MongoDB.Driver?
I downloaded the sample app from https://github.com/Azure-Samples/azure-cosmos-db-mongodb-dotnet-getting-started/archive/master.zip and it is currently indeed in an inconsistent state and it should be fixed by MS.
Project references dlls which cannot be found:
The cause is that Nuget is asked to download MongoDB.BSon 2.6.1, but project references are searching the 2.3.0 folders.
<Reference Include="MongoDB.Driver, Version=2.3.0.157, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Driver.2.3.0\lib\net45\MongoDB.Driver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MongoDB.Driver.Core, Version=2.3.0.157, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Driver.Core.2.3.0\lib\net45\MongoDB.Driver.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MongoDB.Driver.Legacy, Version=2.3.0.157, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\mongocsharpdriver.2.3.0\lib\net45\MongoDB.Driver.Legacy.dll</HintPath>
<Private>True</Private>
</Reference>
I reported the issue to MS, you can track it here: https://github.com/MicrosoftDocs/azure-docs/issues/28204
You could wait for MS to fix it -or- fix the broken references yourself:
You can also simplify the above process by just opening MyTaskListApp.csproj file and making the edits there:
<Reference Include="MongoDB.Bson">
<HintPath>..\packages\MongoDB.Bson.2.6.1\lib\net45\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver">
<HintPath>..\packages\MongoDB.Driver.2.6.1\lib\net45\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver.Core">
<HintPath>..\packages\MongoDB.Driver.Core.2.6.1\lib\net45\MongoDB.Driver.Core.dll</HintPath>
</Reference>
Thanks for your feedback. This is an issue in the csproj file. For which pull request has already been raised. You can refer the pull request to check the ETA for this fix.
https://github.com/Azure-Samples/azure-cosmos-db-mongodb-dotnet-getting-started/pull/8
Hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.