Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Unhandled exception when trying to open a shared conneciton in .net Framework 4.8 #2393

Open
stigzler opened this issue Nov 23, 2023 · 1 comment
Labels

Comments

@stigzler
Copy link

stigzler commented Nov 23, 2023

Version
I am developing on .net Framework 4.8 with LiteDb 5.0.17.0.

Describe the bug
When I try to instantiate a database connection with:

Connection = new LiteDatabase("Filename=C:\\temp\\data.ldb;Connection=Shared");

I get the following error:

System.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'Void System.Threading.Mutex..ctor(Boolean, System.String, Boolean ByRef, System.Security.AccessControl.MutexSecurity)'.
  Source=LiteDB
  StackTrace:
   at LiteDB.SharedEngine..ctor(EngineSettings settings)
   at LiteDB.ConnectionString.CreateEngine()
   at LiteDB.LiteDatabase..ctor(ConnectionString connectionString, BsonMapper mapper)

It works fine if I omit the connection specification. I managed to find a few odds and ends for this through google, but couldn't match to my particular use case. However, it looks like something to do with .net versions and Mutex (which I'm not familiar with)??

I did find this in your docs:

"The Shared mode only works in .NET implementations that provide named mutexes. Its multi-process capabilities will only work in platforms that implement named mutexes as system-wide mutexes."

However, I have no idea what this means, whether this applies to Framework 4.8 or not and indeed what to do as a result.

Any suggestions?

Code to Reproduce

Connection = new LiteDatabase("Filename=C:\\temp\\data.ldb;Connection=Shared");

Expected behavior
Shared Connection is opened

@stigzler stigzler added the bug label Nov 23, 2023
@fil-at-werma
Copy link

I've opened a Bounty of 50 rep for an exhaustive answer to this on Stackoverflow: https://stackoverflow.com/questions/77539735/litedb-throws-unhandled-exception-when-trying-to-open-a-shared-connection

expiring in 7 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants