Bug Report T1272539
Visible to All Users

MongoDBDataSource throws "TypeLoadException: Could not find assembly 'MongoDB.Driver.Core" when the MongoDB.Driver NuGet package v3.0.0+ is used

created a month ago (modified a month ago)

Steps to reproduce:

  1. Use the MongoDBDataSource as demonstrated in the following online example: Reporting for WinForms - Bind a Report to a MongoDB Instance.
  2. Update the MongoDB.Driver NuGet package to v3.0.0 or higher.

Current results:

The following exception is thrown:

Call Stack
DevExpress.DataAccess.MongoDB.DatabaseConnectionException HResult=0x80131500 Message=Failed to connect to the database. To learn more, see the exception details. Exception details: Connection name: Connection Error message: The type initializer for 'DevExpress.DataAccess.Native.MongoDB.MongoDBClient' threw an exception. Source=DevExpress.DataAccess.v24.2 StackTrace: at DevExpress.DataAccess.MongoDB.MongoDBDataConnection.Open(CancellationToken token) at DevExpress.DataAccess.Native.MongoDB.QueryExecutor.ExecuteQueries(MongoDBDataConnection connection, IEnumerable\\\`1 queriesToFill, IList\\\`1 sourceParameters, Int32 schemaDiscoveryMaxItemCount, Boolean includeData, CancellationToken cancellationToken) at DevExpress.DataAccess.MongoDB.MongoDBDataSource.FillCore(String[] queriesToFill, IList\\\`1 sourceParameters, Boolean includeData, CancellationToken cancellationToken) at DevExpress.DataAccess.MongoDB.MongoDBDataSource.RebuildResultSchema() at Bind_a_Report_to_a_MongoDB_Instance.Form1.Form1_Load(Object sender, EventArgs e) in Form1.cs:line 55 at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) This exception was originally thrown at this call stack: DevExpress.Xpo.Helpers.XPTypeActivator.GetType(string, string, bool) DevExpress.DataAccess.Native.MongoDB.MongoDBClient.MongoDBClient() Inner Exception 1: TypeInitializationException: The type initializer for 'DevExpress.DataAccess.Native.MongoDB.MongoDBClient' threw an exception. Inner Exception 2: TypeLoadException: Could not find assembly 'MongoDB.Driver.Core'.

Answers approved by DevExpress Support

created a month ago

We have addressed the issue described in this ticket and will include a fix in our next maintenance update. Should you need to apply our fix prior to official release, you can request a hotfix here.

Important Notes:

  • Hotfixes may be unavailable for Early Access/Beta builds or updates set for release within a week.
  • .NET only: in the NuGet Package Manager, use your personal NuGet feed and check the "Include prerelease" option to view the hotfix package in the "Updates" tab.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.