[CSHARP-4845] System.IO.FileLoadException: Could not load file or assembly 'MongoDB.Driver.Legacy, Culture=neutral, PublicKeyToken=null'. The process cannot access the file because it is being used by another process Created: 17/Nov/23  Updated: 24/Jan/24  Resolved: 24/Jan/24

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Damian Hickey Assignee: Adelin Mbida Owona
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Summary

When running parallel tests in multiple processes, tests will randomly fail. (NCrunch)

System.IO.FileLoadException: Could not load file or assembly 'MongoDB.Driver.Legacy, Culture=neutral, PublicKeyToken=null'. The process cannot access the file because it is being used by another process. (0x80070020)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, StackCrawlMarkHandle stackMark, ObjectHandleOnStack assemblyLoadContext, ObjectHandleOnStack type, ObjectHandleOnStack keepalive)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext)
   at System.Type.GetType(String typeName)
   at MongoDB.Driver.Core.Connections.ClientDocumentHelper.<CreateDriverDocument>gIsLegacyLoaded|6_0()
   at MongoDB.Driver.Core.Connections.ClientDocumentHelper.CreateDriverDocument(String driverVersion)
   at MongoDB.Driver.Core.Connections.ClientDocumentHelper.CreateDriverDocument()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location ---
   at System.Lazy`1.CreateValue()
   at MongoDB.Driver.Core.Connections.ClientDocumentHelper.CreateClientDocument(String applicationName)
   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)

Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

2.19.2 (standalone, docker).

How to Reproduce

Using NCrunch or similar, run tests which will result in the exception, typically within a few seconds. Alternatively churn a single test until failure will result in same.

Additional Background

Please provide any additional background information that may be helpful in diagnosing the bug.



 Comments   
Comment by PM Bot [ 24/Jan/24 ]

There hasn't been any recent activity on this ticket, so we're resolving it. Thanks for reaching out! Please feel free to reopen this ticket if you're still experiencing the issue, and add a comment if you're able to provide more information.

Comment by Damian Hickey [ 28/Nov/23 ]

I will try to prepare a rerpo and put it on github.

Comment by PM Bot [ 28/Nov/23 ]

Hi dhickey@gmail.com! CSHARP-4845 is awaiting your response.

If this is still an issue for you, please open Jira to review the latest status and provide your feedback. Thanks!

Comment by Adelin Mbida Owona [ 20/Nov/23 ]

Hi dhickey@gmail.com, can you please provide more detailed info on how to reproduce this bug such as code setup/environment setup?

Comment by PM Bot [ 17/Nov/23 ]

Hi dhickey@gmail.com, thank you for reporting this issue! The team will look into it and get back to you soon.

Generated at Wed Feb 07 21:49:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.