-
Type: Bug
-
Resolution: Fixed
-
Priority: Blocker - P1
-
Affects Version/s: 2.22.0
-
Component/s: None
-
Fully Compatible
-
Not Needed
-
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.