-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Sequence contains no elements at 5.0.0-alpha #1275
Comments
I ran into the same problem. It only occurs when I create the database completely new (0kB file). The Exception is thrown on |
Yeah I've got the same problem with Xamarin.Forms 4.5.
I switched back to 4.1.4. |
Also 5.0.7 |
@VasenevEA @Enviolet @bluekuen @biapar This error is probably happening because LiteDB is trying to open a zero-byte file (which is obviously not a valid datafile). We'll release a fix for this eventually, but in the meantime just make sure the file you're trying to open is a valid datafile (and not a zero-byte file). |
yeah that was the problem, i fixed it by deleting the file creation:
Many thanks for your help! |
"Fix this eventually"? I just came across this problem and it seems like it should be a relatively simply fix to check for a zero byte file and act accordingly. It's something people are quite likely to do when creating a new DB so I think you guys should fix it ASAP. |
Is this fixed already? |
2020-10-26 Windows 10 x64 using LiteDB;
using System.IO;
namespace LiteDBTest
{
internal class Program
{
private static void Main(string[] args)
{
var connectionString = new ConnectionString
{
Filename = Path.GetTempFileName(), // Create temporary zero-length file.
};
// File.Delete(connectionString.Filename); // Workaround.
try
{
using (var db = new LiteDatabase(connectionString)) // System.InvalidOperationException: "Sequence contains no elements".
{
var names = db.GetCollectionNames();
}
}
finally
{
File.Delete(connectionString.Filename);
}
}
}
} Stack trace:
|
This has apparently been fixed, and the bug should probably be closed; see: #1956 |
Every operation with collection throw System.InvalidOperationException.
Framework: Xamarin.Forms
Platform: Android OS
Library Version: 5.0.0-alpha
Code to reproduce:
Also Insert, Delete, Find will throw
System.InvalidOperationException: Sequence contains no elements
StackTrace:
The text was updated successfully, but these errors were encountered: