What App Center service does this affect?
2.2.1-preview WPF
Describe the bug
Application crashes when calling AppCenter.Start, after the application is installed via msix (self signed). No problem whatsoever when running from Visual Studio (2019), both in debug and release. Also no problem when running the exe directly.
To Reproduce
Steps to reproduce the behavior:
EventLog
Application: AppCenterWPF.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.UnauthorizedAccessException
at System.IO.__Error.WinIOError(Int32, System.String)
at System.IO.FileStream.Init(System.String, System.IO.FileMode, System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean, Boolean)
at System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess)
at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated()
at System.CodeDom.Compiler.TempFileCollection.AddExtension(System.String, Boolean)
at System.Configuration.Internal.WriteFileContext..ctor(System.String, System.String)
at System.Configuration.Internal.InternalConfigHost.StaticOpenStreamForWrite(System.String, System.String, System.Object ByRef, Boolean)
at System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.OpenStreamForWrite(System.String, System.String, System.Object ByRef, Boolean)
at System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.OpenStreamForWrite(System.String, System.String, System.Object ByRef)
at System.Configuration.ClientConfigurationHost.OpenStreamForWrite(System.String, System.String, System.Object ByRef)
at System.Configuration.UpdateConfigHost.OpenStreamForWrite(System.String, System.String, System.Object ByRef)
at System.Configuration.MgmtConfigurationRecord.SaveAs(System.String, System.Configuration.ConfigurationSaveMode, Boolean)
Exception Info: System.Configuration.ConfigurationErrorsException
at System.Configuration.MgmtConfigurationRecord.SaveAs(System.String, System.Configuration.ConfigurationSaveMode, Boolean)
at System.Configuration.Configuration.SaveAsImpl(System.String, System.Configuration.ConfigurationSaveMode, Boolean)
at Microsoft.AppCenter.Utils.DefaultApplicationSettings.SaveValue(System.String, System.String)
at Microsoft.AppCenter.Utils.DefaultApplicationSettings.SetValue(System.String, System.Object)
at Microsoft.AppCenter.Utils.DefaultApplicationSettings.GetValue[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.String, System.Guid)
at Microsoft.AppCenter.AppCenter.PlatformGetInstallIdAsync()
at Microsoft.AppCenter.Utils.Constants.get_AppCenterFilesDirectoryPath()
at Microsoft.AppCenter.Utils.Constants..cctor()
Exception Info: System.TypeInitializationException
at Microsoft.AppCenter.Storage.Storage.DefaultAdapter()
at Microsoft.AppCenter.AppCenter.InstanceConfigure(System.String)
at Microsoft.AppCenter.AppCenter.PlatformStart(System.String, System.Type[])
at AppCenterWPF.App.SetupAppCenter()
at AppCenterWPF.App.OnStartup(System.Windows.StartupEventArgs)
at System.Windows.Application.<.ctor>b__1_0(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
at System.Windows.Application.Run(System.Windows.Window)
at AppCenterWPF.App.Main()
Faulting application name: AppCenterWPF.exe, version: 1.0.0.0, time stamp: 0xcbc73ca8
Faulting module name: KERNELBASE.dll, version: 10.0.18362.239, time stamp: 0xe665f337
Exception code: 0xe0434352
Fault offset: 0x00113442
Faulting process id: 0x5b94
Faulting application start time: 0x01d550606a31ebc9
Faulting application path: C:\Program Files\WindowsApps\9f64f8fa-ac6b-43cf-8709-464447b44c72_1.0.8.0_x64__mdpx8chr8ka72\AppCenterWPF\AppCenterWPF.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: 23b395df-9c05-47a9-9b96-7dfab2a6abe8
Faulting package full name: 9f64f8fa-ac6b-43cf-8709-464447b44c72_1.0.8.0_x64__mdpx8chr8ka72
Faulting package-relative application ID: App
Expected behavior
Application to start
Desktop (please complete the following information):
I'm seeing the same sequence of exceptions. Tried AppCenter.Start( ) for the first time. We also have a WPF app packaged in MSIX.
Hi there @PieEatingNinjas @keithrowe though we didn't manage to reproduce this, looks like there is an issue. I created a ticket to investigate this, we will keep you updated on the progress.
Hey @PieEatingNinjas,
Thanks for reporting this issue with detailed repro steps. I was able to follow it through and got a repro with the same System.UnauthorizedAccessException error.
I believe the error is caused by a permission issue with the sandboxed MSIX-packaged WPF apps. If the app is not using MSIX, it should be fine.
Exception Info: System.Configuration.ConfigurationErrorsException
at System.Configuration.MgmtConfigurationRecord.SaveAs(System.String, System.Configuration.ConfigurationSaveMode, Boolean)
at System.Configuration.Configuration.SaveAsImpl(System.String, System.Configuration.ConfigurationSaveMode, Boolean)
at Microsoft.AppCenter.Utils.DefaultApplicationSettings.SaveValue(System.String, System.String)
at Microsoft.AppCenter.Utils.DefaultApplicationSettings.SetValue(System.String, System.Object)
at Microsoft.AppCenter.Utils.DefaultApplicationSettings.GetValue[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.String, System.Guid)
at Microsoft.AppCenter.AppCenter.PlatformGetInstallIdAsync()
at Microsoft.AppCenter.Utils.Constants.get_AppCenterFilesDirectoryPath()
at Microsoft.AppCenter.Utils.Constants..cctor()
WPF SDK's DefaultApplicationSettings class was trying to access System configuration which is inaccessible to MSIX-sandboxed WPF apps, therefore got System.UnauthorizedAccessException error and crashing the app.
We will further investigate and update this thread when we have more to share.
I am getting the same issue on my project but by using different scenario. Could you also check that when executable has wrapped all the assemblies as embedded resources, the application gets started?
I am using Constura.Fody (https://github.com/Fody/Costura 4.0 for embedded references as resources)
Thanks.
My app isn't in an app container and gets installed as a 32bit application in Program Files but still has a similar symptom. Trying to create a temp file in the program files directory.
System.TypeInitializationException: The type initializer for 'Microsoft.AppCenter.Utils.Constants' threw an exception. ---> System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Access to the path 'C:\Program Files (x86)\[CompanyName]\[AppName]\tnasxwnb.tmp' is denied. (C:\Program Files (x86)\[CompanyName]\[AppName]\AppCenter.config) ---> System.UnauthorizedAccessException: Access to the path 'C:\Program Files (x86)\[CompanyName]\[AppName]\tnasxwnb.tmp' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated()
at System.CodeDom.Compiler.TempFileCollection.AddExtension(String fileExtension, Boolean keepFile)
at System.Configuration.Internal.WriteFileContext..ctor(String filename, String templateFilename)
at System.Configuration.Internal.InternalConfigHost.StaticOpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext, Boolean assertPermissions)
at System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.OpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext, Boolean assertPermissions)
at System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.OpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext)
at System.Configuration.ClientConfigurationHost.OpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext)
at System.Configuration.UpdateConfigHost.OpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext)
at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll)
--- End of inner exception stack trace ---
at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll)
at System.Configuration.Configuration.SaveAsImpl(String filename, ConfigurationSaveMode saveMode, Boolean forceSaveAll)
at Microsoft.AppCenter.Utils.DefaultApplicationSettings.SaveValue(String key, String value)
at Microsoft.AppCenter.Utils.DefaultApplicationSettings.SetValue(String key, Object value)
at Microsoft.AppCenter.Utils.DefaultApplicationSettings.GetValue[T](String key, T defaultValue)
at Microsoft.AppCenter.AppCenter.PlatformGetInstallIdAsync()
at Microsoft.AppCenter.Utils.Constants.get_AppCenterFilesDirectoryPath()
at Microsoft.AppCenter.Utils.Constants..cctor()
--- End of inner exception stack trace ---
at Microsoft.AppCenter.Storage.Storage.DefaultAdapter()
at Microsoft.AppCenter.AppCenter.InstanceConfigure(String appSecretOrSecrets)
at Microsoft.AppCenter.AppCenter.PlatformStart(String appSecret, Type[] services)
at Secretariat.WPF.App.OnStartup(StartupEventArgs e)
at System.Windows.Application.<.ctor>b__1_0(Object unused)
We changed the path of the config file to be in a user based directory in version 2.3.0-preview, can you try updating the nugets and test?
I updated my NuGet packages, re-packaged my app, distributed through AppCenter and everything is working now!
Great job, guys!
Glad to hear that issue is sorted out :) Closing the thread now.