microsoft / appcenter-sdk-dotnet

Development repository for the App Center SDK for .NET platforms, including Xamarin
Other
308 stars 141 forks source link

Unable to save config file exception #1109

Closed nabeelio closed 4 years ago

nabeelio commented 5 years ago

Description

Other details are the same as my previous issue #1068

Repro Steps

Please list the steps used to reproduce your issue.

  1. Call start

Details

Using the latest prerelease version in a WPF project.

System.TypeInitializationException
  HResult=0x80131534
  Message=The type initializer for 'Microsoft.AppCenter.Utils.Constants' threw an exception.
  Source=Microsoft.AppCenter
  StackTrace:
   at Microsoft.AppCenter.Storage.Storage.DefaultAdapter()
   at Microsoft.AppCenter.AppCenter.InstanceConfigure(String appSecretOrSecrets)
   at Microsoft.AppCenter.AppCenter.PlatformStart(String appSecret, Type[] services)
   at Microsoft.AppCenter.AppCenter.Start(String appSecret, Type[] services)
   at Acars.App.CreateShell() in C:\Users\Nabeel\source\repos\ACARS\AcarsClient\App.xaml.cs:line 91
   at Prism.PrismApplicationBase.Initialize() in d:\a\1\s\Source\Wpf\Prism.Wpf\PrismApplicationBase.cs:line 84
   at Prism.PrismApplicationBase.InitializeInternal() in d:\a\1\s\Source\Wpf\Prism.Wpf\PrismApplicationBase.cs:line 46
   at Prism.PrismApplicationBase.OnStartup(StartupEventArgs e) in d:\a\1\s\Source\Wpf\Prism.Wpf\PrismApplicationBase.cs:line 37
   at System.Windows.Application.<.ctor>b__1_0(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at Acars.App.Main()

Inner Exception 1:
ConfigurationErrorsException: Unable to save config to file 'C:\Users\...\AppData\Local\phpVMS\acars.exe_Url_qvl4ekumnzcu5otwp4l1ouhhyqs0jrdk\AppCenter.config'.

And the verbose logs:

'acars.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Users\Nabeel\source\repos\ACARS\AcarsClient\bin\Debug\acars.exe'. Symbols loaded.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'Prism.Unity.Wpf'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'Prism.Wpf'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'Prism'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PrivateAssemblies\Runtime\Microsoft.VisualStudio.Debugger.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\Users\Nabeel\AppData\Local\Temp\VisualStudio.XamlDiagnostics.3608\Microsoft.VisualStudio.DesignTools.WpfTap.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\SMDiagnostics\v4.0_4.0.0.0__b77a5c561934e089\SMDiagnostics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Internals\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Internals.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'Newtonsoft.Json'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'MahApps.Metro'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Aero2\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Aero2.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ValueTuple\v4.0_4.0.0.0__cc7b13ffcd2ddd51\System.ValueTuple.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'Unity.Abstractions'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'Unity.Container'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'CommonServiceLocator'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'NLog'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'LiteDB'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'RestSharp'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'Polly'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'FSUIPCClient'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Resolving Prism.Regions.SelectorRegionAdapter for 
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'System.Runtime.CompilerServices.Unsafe'. Module was built without symbols.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Resolving Prism.Regions.ItemsControlRegionAdapter for 
Resolving Prism.Regions.ContentControlRegionAdapter for 
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'Microsoft.AppCenter'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'Microsoft.AppCenter.Analytics'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'Microsoft.AppCenter.Crashes'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
2019-09-07 12:07:21.397 [AppCenter] WARN: Could not check/migrate old config file
System.ArgumentException: The path is not of a legal form.
   at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.InternalGetDirectoryName(String path)
   at Microsoft.AppCenter.Utils.DefaultApplicationSettings.OpenConfiguration()
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'acars.exe' (CLR v4.0.30319: acars.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
2019-09-07 12:07:21.422 [AppCenter] DEBUG: No named identifier found in appSecret; using as-is
2019-09-07 12:07:21.429 [AppCenter] DEBUG: Enabled TLS 1.2 explicitly as it was disabled.
Exception thrown: 'System.TypeInitializationException' in Microsoft.AppCenter
An unhandled exception of type 'System.TypeInitializationException' occurred in Microsoft.AppCenter
The type initializer for 'Microsoft.AppCenter.Utils.Constants' threw an exception.
guperrot commented 5 years ago

Sounds like your own user cannot write to C:\Users\...\AppData\Local\phpVMS\acars.exe_Url_qvl4ekumnzcu5otwp4l1ouhhyqs0jrdk\AppCenter.config which is the user directory.

Does the C:\Users\...\AppData\Local\phpVMS\acars.exe_Url_qvl4ekumnzcu5otwp4l1ouhhyqs0jrdk parent directory exist?

nabeelio commented 5 years ago

It exists, and I deleted the folder and it was recreated on app startup, but still the same permissions error. The permissions on the folder itself are full to my user.

permissions

nabeelio commented 5 years ago

And the app.manifest file is just the default:


<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
  <!--
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        ~1~ UAC Manifest Options
             If you want to change the Windows User Account Control level replace the 
             requestedExecutionLevel node with one of the following.

        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />

            Specifying requestedExecutionLevel element will disable file and registry virtualization. 
            Remove this element if your application requires this virtualization for backwards
            compatibility.
        @1@
        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
      </requestedPrivileges>
      <applicationRequestMinimum>
        <defaultAssemblyRequest permissionSetReference="Custom" />
        <PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" />
      </applicationRequestMinimum>
    </security>
  </trustInfo>-->
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!-- A list of the Windows versions that this application has been tested on and is
           is designed to work with. Uncomment the appropriate elements and Windows will 
           automatically selected the most compatible environment. -->
      <!-- Windows Vista -->
      <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
      <!-- Windows 7 -->
      <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
      <!-- Windows 8 -->
      <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
      <!-- Windows 8.1 -->
      <!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
      <!-- Windows 10 -->
      <!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
    </application>
  </compatibility>
  <!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
       DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need 
       to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should 
       also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
  <!--
  <application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
    </windowsSettings>
  </application>
  -->
  <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
  <!--
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
          type="win32"
          name="Microsoft.Windows.Common-Controls"
          version="6.0.0.0"
          processorArchitecture="*"
          publicKeyToken="6595b64144ccf1df"
          language="*"
        />
    </dependentAssembly>
  </dependency>
  -->
</assembly>```
nabeelio commented 5 years ago

And I have written files to that folder in the past

nabeelio commented 5 years ago

So I removed the app.manifest entirely and it seems to be working now. I'm guessing that's something that would need to be addressed somewhere in the docs or what values I might need to put in there, if I needed to use the manifest file.

guperrot commented 5 years ago

That sounds like a bug we need to fix to be compatible with something in your manifest. Do you mind sharing that file as it was when the issue occurred?

nabeelio commented 5 years ago

Sounds good, thanks. It's the one I posted above.

guperrot commented 4 years ago

I generated the default manifest and it looks like yours. However I don't have any issue with it. I used this method: https://stackoverflow.com/a/55462107/598520 It would be interesting to compare our csproj files if you need to restore the manifest (adding the manifest generates a lot of diff in the csproj file). But since it works with or without the default manifest for us, I don't see anything to document for now.

guperrot commented 4 years ago

Actually my file didn't have sections commented out, but after I replaced with the one you shared to have the same sections commented out, no issue either. I suspect csproj differences instead.

annakocheshkova commented 4 years ago

Hey @nabeelio do you have any updates? If so, please let us know and re-open the issue. Thanks.