I just created a new windows 8 app in c#/XML and download mongodb c# driver and add its reference in my project and follows the rest of tutorial , but when i try to run my app now its saying
Cannot resolve Assembly or Windows Metadata file 'System.Data.dll'
Type universe cannot resolve assembly: System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
Please help me thanks in advance .
Looks like system.data
is unavailable to metro apps. The general consensus seems to be that you'll have to create a middle "go-between" tier (using a technology such as WCF) to allow your metro app to communication with the database.
References:
Although these links have SQL in the title, they really address connecting metro apps directly to any database.
Here's a bit from an answer at one of the above links:
You are correct, System.Data is not there (I looked for the same thing when I first started messing around with WinRT). You won't be able to reference it either. If you want to talk to a SQL database you're going to need to use some kind of other protocol (WebService, SOAP, WCF, etc.).
Followup question in comment:
I am trying to connect with mongodb , not sql . Is it necessary to have system.data for this purpose ?
When I tried this, I could reference MongoDB.Bson.dll
by itself and the project builds, but once I referenced MongoDB.Driver.dll
I got the same message as you.
It would appear the sql driver and the mongodb driver both require System.Data.dll
, which you could reference directly in a standard winforms/wpf app (but probably shouldn't), but which you cannot reference directly in a metro app.
I'd say it's necessary to have access to System.Data
if you want to use MongoDB. So you'll have to create a separate project that references the MongoDB driver and actually performs the connections to the database, and make that project accessible to your metro app via WCF calls or a web service. You just need something sitting between your metro app and the database, because you cannot connect directly to it.
I know it seems to make things more complicated, especially if you're just trying to play around, but it's apparently a design decision Microsoft made regarding their metro apps.
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