오늘 저는 SQL Ce에서 MongoDB로 옮기고 싶었습니다. 드라이버를 다운로드하고 서버를 로컬 PC에서 실행했습니다.아마도 MongoDB의 비정상적인 오류입니까?
가 여기 내 실제 코드입니다 (BTW 나는 심지어 MongoCollection에 IMongoCollection 캐스팅하는 것이 안전 알고하지 않습니다) : 처리되지 않은를 :
using System;
using MongoDB.Driver;
namespace MongoShit
{
class Program
{
class Apple
{
public int price, weight;
public string color;
public Apple()
{
price = 0;
weight = 0;
color = "ayye";
}
}
static protected IMongoClient client;
static protected IMongoDatabase database;
static void Main(string[] args)
{
client = new MongoClient("mongodb://localhost");
database = client.GetDatabase("test");
database.CreateCollection("apples");
var data = new Apple() { price = 100, weight = 500, color = "green" };
MongoCollection<Apple> collection = (MongoCollection<Apple>)database.GetCollection<Apple>("apples");
collection.Insert(data);
var cursor = collection.FindAll();
foreach(Apple a in cursor)
{
Console.WriteLine(string.Format("Apple, P: {0} W: {1} C: {2}", new object[] { a.price, a.weight, a.color }));
}
Console.Read();
}
}
}
을하지만, 나는 다음과 같은 오류가 프로그램을 실행하려고 할 때마다 유형 'System.IO.FileNotFoundException'의 예외가 mscorlib.dll에서
추가 정보 발생 : 파일이나 어셈블리를로드 할 수 없습니다 'System.Runtime.InteropServices.RuntimeInformation, 버전 = 4.0.0.0을, 문화 = 중립, PublicKeyToken = b03f5f7f11d50a3a '또는 그 의존성 중 하나. 시스템이 지정된 파일을 찾을 수 없습니다.
무슨 일 이니? : 당신은 MongoCollection에 캐스트 할 필요가없는 S