Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-4843

Suppress any exceptions in the code checking for legacy driver loaded

    • Fully Compatible
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Summary

      When using MongoDB Driver from NuGet, v 2.22.0

      When instantiating an **

      new MongoClient(connectionString)

       instance, with a connection string pointing to

      mongodb://localhost:27017

      The MongoClient object is called from a .Net 2.0 Standard library with 4.8 as Target, it runs as a Windows Service.
       
      I get the following error.
       

      "exception": "System.NullReferenceException: Object reference not set to an instance of an object.
      at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
      at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
      at System.Type.GetType(String typeName)
      at MongoDB.Driver.Core.Connections.ClientDocumentHelper.<CreateDriverDocument>g__IsLegacyLoaded|9_0()
      at MongoDB.Driver.Core.Connections.ClientDocumentHelper.CreateDriverDocument(String driverVersion)
      at System.Lazy`1.CreateValue()
      — End of stack trace from previous location where exception was thrown —
      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
      at System.Lazy`1.get_Value()
      at MongoDB.Driver.Core.Connections.ClientDocumentHelper.CreateClientDocument(String applicationName)
      at MongoDB.Driver.Core.Connections.ConnectionInitializer..ctor(String applicationName, IReadOnlyList`1 compressors, ServerApi serverApi)
      at MongoDB.Driver.Core.Connections.BinaryConnectionFactory..ctor(ConnectionSettings settings, IStreamFactory streamFactory, IEventSubscriber eventSubscriber, ServerApi serverApi, ILoggerFactory loggerFactory)
      at MongoDB.Driver.Core.Configuration.ClusterBuilder.CreateConnectionPoolFactory()
      at MongoDB.Driver.Core.Configuration.ClusterBuilder.CreateServerFactory()
      at MongoDB.Driver.Core.Configuration.ClusterBuilder.CreateClusterFactory()
      at MongoDB.Driver.ClusterRegistry.CreateCluster(ClusterKey clusterKey)
      at MongoDB.Driver.ClusterRegistry.GetOrCreateCluster(ClusterKey clusterKey)
      at MongoDB.Driver.MongoClient..ctor(MongoClientSettings settings)

      The same library has no issues connecting to the same Mongo instance when running inside of an Asp.Net 4.8 service.

            Assignee:
            oleksandr.poliakov@mongodb.com Oleksandr Poliakov
            Reporter:
            wamra2004-developer@yahoo.com Wesam Abdallah
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: