Skip to content

Microsoft.Data.Sqlite throws InvalidOperationException when unpackaged #38275

@torum

Description

@torum

Bug description

Microsoft.Data.Sqlite throws System.InvalidOperationException: 'Operation is not valid due to the current state of the object.' when running as an unpackaged WinUI3 app.

Microsoft.Data.Sqlite calls Windows.Storage.ApplicationData.Current which results in the exception because Windows.Storage.ApplicationData require package identity.

Your code

new SqliteConnection("Data Source=C:\\Users\\me\\test.db")`

Stack traces

[System.InvalidOperationException thrown]	
 	WinRT.Runtime.dll!WinRT.ExceptionHelpers.ThrowExceptionForHR.__Throw|38_0(int hr)	Unknown
 	WinRT.Runtime.dll!WinRT.ExceptionHelpers.ThrowExceptionForHR(int hr)	Unknown
 	Microsoft.Windows.SDK.NET.dll!ABI.Windows.Storage.IApplicationDataStaticsMethods.get_Current(WinRT.IObjectReference _obj)	Unknown
 	Microsoft.Windows.SDK.NET.dll!Windows.Storage.ApplicationData.Current.get()	Unknown
 	[Lightweight Function]	
 	System.Private.CoreLib.dll!System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(object obj, System.Reflection.BindingFlags invokeAttr)	Unknown
 	Microsoft.Data.Sqlite.dll!Microsoft.Data.Sqlite.SqliteConnection.SqliteConnection()	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	Microsoft.Data.Sqlite.dll!Microsoft.Data.Sqlite.SqliteConnection.SqliteConnection(string connectionString)	Unknown

Microsoft.Data.Sqlite version

10.0.8

Target framework

.NET 10

Operating system

Windows 11

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions