You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create an unpackaged MAUI app for a certain deployment scenario. Our application uses MonkeyCache. When I start the application, it fails with an InvalidOperationException. The call stack implies it's failing when it uses Windows.Storage.ApplicationData.get_Current(), which I presume requires MSIX packaging to work properly.
I validated this by doing as follows:
Create a new MAUI application using the VS templates.
Edit the .csproj to produce an unpackaged app by adding <WindowsPackageType>None</WindowsPackageType>.
Update the launchSettings.json file to not use package actions by changing command to "Project".
System.InvalidOperationException: Operation is not valid due to the current state of the object.
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|39_0(Int32 hr)
at WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr)
at ABI.Windows.Storage.IApplicationDataStaticsMethods.get_Current(IObjectReference _obj)
at Windows.Storage.ApplicationData.get_Current()
at MonkeyCache.BarrelUtils.GetBasePath(String applicationId)
at MonkeyCache.SQLite.MonkeyBarrel.<>c.<.cctor>b__32_0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at MonkeyCache.SQLite.MonkeyBarrel..ctor(String cacheDirectory)
at MonkeyCache.SQLite.MonkeyBarrel.get_Current()
at [my redacted call site]
I'm looking at the code and the most inelegant fix would be a try..catch in the #if WINDOWS section. If it used the Environment.GetFolderPath() method as a fallback that would work here. I'm not sure if there's a way this code could tell if it's been packaged or not so that might be the solution?
The text was updated successfully, but these errors were encountered:
I'm trying to create an unpackaged MAUI app for a certain deployment scenario. Our application uses MonkeyCache. When I start the application, it fails with an
InvalidOperationException
. The call stack implies it's failing when it usesWindows.Storage.ApplicationData.get_Current()
, which I presume requires MSIX packaging to work properly.I validated this by doing as follows:
<WindowsPackageType>None</WindowsPackageType>
.launchSettings.json
file to not use package actions by changingcommand
to "Project".MainPage.xaml.cs
:The call stack:
I'm looking at the code and the most inelegant fix would be a try..catch in the
#if WINDOWS
section. If it used theEnvironment.GetFolderPath()
method as a fallback that would work here. I'm not sure if there's a way this code could tell if it's been packaged or not so that might be the solution?The text was updated successfully, but these errors were encountered: