简体   繁体   中英

How do I use the MongoDB C# driver with a UWP app?

So I am trying to build a small interface for a side project. I have a private MongoDB instance and am trying to use UWP as my GUI. My goal was to use the MongoDB C# driver to provide the interface between my app and the server. The problem is the driver is only compatible with .NET Framework 4.5.2 or .NET standard 1.5.

I am having problems selecting a library type to use with my UWP app to interface the two. Any Ideas? If I have to I am even willing to spin off an additional library just to handle the interface of the driver and my model classes.

As you've known, MongoDB.Driver targets .NET Standard 1.5 . However, for now, the highest version of .NET Standard that Universal Windows Platform supports is 1.4 , which means this package is not compatible with UWP apps. So we can't use MongoDB C# Driver with a UWP app now. For more info, please see .NET Standard .

But a good news is that .NET Standard 2.0 has released and UWP will also support it in the upcoming version (expected to ship later this year). See Announcing .NET Standard 2.0 . With .NET Standard 2.0, we should be able to MongoDB C# Driver in UWP apps. And if you want to do a test now, you can join Windows Insider Program and try with Visual Studio 2017 Version 15.4 Preview .

Visual Studio 2017 version 15.4 Preview brings first class support for developers targeting the Windows Fall Creators Update SDK preview. The Windows Fall Creators Update brings support for .NET Standard 2.0 to UWP development.

For more info, please see Visual Studio 2017 Version 15.4 Preview and UWP & .NET Standard 2.0: A preview is now available!

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM