Could not load file or assembly 'MongoDB.Bson, Version=1.7.0.4714, Culture=neutral, PublicKeyToken=f686731cfb9cc103' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) - OmIndia

Teach To India

Friday, August 11, 2017

Could not load file or assembly 'MongoDB.Bson, Version=1.7.0.4714, Culture=neutral, PublicKeyToken=f686731cfb9cc103' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Server Error in '/' Application.

Could not load file or assembly 'MongoDB.Bson, Version=1.7.0.4714, Culture=neutral, PublicKeyToken=f686731cfb9cc103' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'MongoDB.Bson, Version=1.7.0.4714, Culture=neutral, PublicKeyToken=f686731cfb9cc103' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Source Error:


Line 26:     {
Line 27:       string conn = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
Line 28:         MongoClient _client = new MongoClient("conn");
Line 29:         MongoServer server = _client.GetServer();
Line 30:         MongoDatabase db=server.GetDatabase("Book");

Source File: d:\Yogendra\MyPractise\TestWebsite\Default.aspx.cs    Line: 28

Assembly Load Trace: The following information can be helpful to determine why the assembly 'MongoDB.Bson, Version=1.7.0.4714, Culture=neutral, PublicKeyToken=f686731cfb9cc103' could not be loaded.


*****************Solution -********************

        protected void Button1_Click(object sender, EventArgs e)

    {

        var conn = ConfigurationManager.ConnectionStrings["con"].ConnectionString;

        MongoClient _client = new MongoClient(conn);

        MongoServer server = _client.GetServer();

        MongoDatabase db = server.GetDatabase("Book");

        var list = db.GetCollection("BookName").FindAll();

        //grd_view.DataSource = list;

        //grd_view.DataBind();


        


2 comments:

  1. Which way is better? Save a media file to MongoDB as array of bytes or as string?

    ReplyDelete
  2. private static void Statistics(string collectionName)
    {
    new BsonDocument { { "collstats", collectionName } };
    var command = new BsonDocumentCommand(new BsonDocument { { "collstats", collectionName } });
    var stats = mongoDb.RunCommand(command);

    Console.WriteLine($" * Collection : {collectionName}");
    Console.WriteLine($" * Count : {stats["count"].AsInt32} documents");
    Console.WriteLine($" * Average Doc Size: {stats["avgObjSize"].AsInt32} bytes");
    Console.WriteLine($" * Total Storage : {stats["storageSize"].AsInt32} bytes");
    Console.WriteLine("\n");
    }

    ReplyDelete

Comments

Popular