dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.24k stars 4.73k forks source link

Test Save_SimpleSettings_Ok failing #28833

Open maryamariyan opened 5 years ago

maryamariyan commented 5 years ago

This issue tracks the Linux failures on Save_SimpleSettings_Ok, a test that is added in PR https://github.com/dotnet/corefx/pull/28894. The Linux issue may be something weird about how our machines are configured on our CI machines.

Failing on Linux with:

2018-06-12 18:36:32,792: INFO: proc(54): run_and_log_output: Output:    System.ConfigurationTests.ApplicationSettingsBaseTests.Save_SimpleSettings_Ok(isSynchronized: True) [FAIL]
2018-06-12 18:36:32,794: INFO: proc(54): run_and_log_output: Output:       System.Configuration.ConfigurationErrorsException : Failed to save settings: An error occurred loading a configuration file: An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.
2018-06-12 18:36:32,795: INFO: proc(54): run_and_log_output: Output:       ---- System.Configuration.ConfigurationErrorsException : An error occurred loading a configuration file: An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.
2018-06-12 18:36:32,795: INFO: proc(54): run_and_log_output: Output:       -------- System.InvalidOperationException : An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.
2018-06-12 18:36:32,803: INFO: proc(54): run_and_log_output: Output:       Stack Trace:
2018-06-12 18:36:32,836: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/ClientSettingsStore.cs(209,0): at System.Configuration.ClientSettingsStore.WriteSettings(String sectionName, Boolean isRoaming, IDictionary newSettings)
2018-06-12 18:36:32,837: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/LocalFileSettingsProvider.cs(220,0): at System.Configuration.LocalFileSettingsProvider.SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection values)
2018-06-12 18:36:32,837: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsBase.cs(129,0): at System.Configuration.SettingsBase.SaveCore()
2018-06-12 18:36:32,838: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsBase.cs(115,0): at System.Configuration.SettingsBase.Save()
2018-06-12 18:36:32,838: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/tests/System/Configuration/ApplicationSettingsBaseTests.cs(135,0): at System.ConfigurationTests.ApplicationSettingsBaseTests.Save_SimpleSettings_Ok(Boolean isSynchronized)
2018-06-12 18:36:32,838: INFO: proc(54): run_and_log_output: Output:          ----- Inner Stack Trace -----
2018-06-12 18:36:32,840: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs(1098,0): at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll)
2018-06-12 18:36:32,840: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/ClientSettingsStore.cs(204,0): at System.Configuration.ClientSettingsStore.WriteSettings(String sectionName, Boolean isRoaming, IDictionary newSettings)
2018-06-12 18:36:32,840: INFO: proc(54): run_and_log_output: Output:          ----- Inner Stack Trace -----
2018-06-12 18:36:32,840: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigurationHost.cs(312,0): at System.Configuration.ClientConfigurationHost.OpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext)
2018-06-12 18:36:32,841: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs(1062,0): at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll)
2018-06-12 18:36:32,843: INFO: proc(54): run_and_log_output: Output:    System.ConfigurationTests.ApplicationSettingsBaseTests.Save_SimpleSettings_Ok(isSynchronized: False) [FAIL]
2018-06-12 18:36:32,843: INFO: proc(54): run_and_log_output: Output:       System.Configuration.ConfigurationErrorsException : Failed to save settings: An error occurred loading a configuration file: An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.
2018-06-12 18:36:32,843: INFO: proc(54): run_and_log_output: Output:       ---- System.Configuration.ConfigurationErrorsException : An error occurred loading a configuration file: An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.
2018-06-12 18:36:32,843: INFO: proc(54): run_and_log_output: Output:       -------- System.InvalidOperationException : An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.
2018-06-12 18:36:32,844: INFO: proc(54): run_and_log_output: Output:       Stack Trace:
2018-06-12 18:36:32,844: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/ClientSettingsStore.cs(209,0): at System.Configuration.ClientSettingsStore.WriteSettings(String sectionName, Boolean isRoaming, IDictionary newSettings)
2018-06-12 18:36:32,844: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/LocalFileSettingsProvider.cs(220,0): at System.Configuration.LocalFileSettingsProvider.SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection values)
2018-06-12 18:36:32,844: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsBase.cs(129,0): at System.Configuration.SettingsBase.SaveCore()
2018-06-12 18:36:32,849: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsBase.cs(122,0): at System.Configuration.SettingsBase.Save()
2018-06-12 18:36:32,849: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/tests/System/Configuration/ApplicationSettingsBaseTests.cs(135,0): at System.ConfigurationTests.ApplicationSettingsBaseTests.Save_SimpleSettings_Ok(Boolean isSynchronized)
2018-06-12 18:36:32,849: INFO: proc(54): run_and_log_output: Output:          ----- Inner Stack Trace -----
2018-06-12 18:36:32,850: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs(1098,0): at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll)
2018-06-12 18:36:32,850: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/ClientSettingsStore.cs(204,0): at System.Configuration.ClientSettingsStore.WriteSettings(String sectionName, Boolean isRoaming, IDictionary newSettings)
2018-06-12 18:36:32,850: INFO: proc(54): run_and_log_output: Output:          ----- Inner Stack Trace -----
2018-06-12 18:36:32,851: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigurationHost.cs(312,0): at System.Configuration.ClientConfigurationHost.OpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext)
2018-06-12 18:36:32,851: INFO: proc(54): run_and_log_output: Output:          /mnt/j/workspace/dotnet_corefx/master/linux-TGroup_netcoreapp+CGroup_Release+AGroup_x64+TestOuter_false_prtest/src/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs(1062,0): at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll)

(Taken from comment https://github.com/dotnet/corefx/pull/28894#issuecomment-396789297)

ViktorHofer commented 5 years ago

Failed again, this time on Windows 7: https://dev.azure.com/dnceng/public/_build/results?buildId=358032&view=ms.vss-test-web.build-test-results-tab&runId=10839480&resultId=105888&paneView=debug

Configuration: netcoreapp-Windows_NT-Release-x86-Windows.7.Amd64.Open

System.ConfigurationTests.ApplicationSettingsBaseTests.Save_SimpleSettings_Ok(isSynchronized: False)

System.Configuration.ConfigurationErrorsException : An error occurred creating the configuration section handler for userSettings/System.ConfigurationTests.ApplicationSettingsBaseTests_x002B_PersistedSimpleSettings: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. (C:\\Users\\runner\\AppData\\Local\\Microsoft_Corporation\\xunit.console_StrongName_vmuqnj1rm2vzmtjlxpznjgrpuvgx0hav\\2.5.1.0\\user.config line 5)\r\n---- System.IO.FileNotFoundException : Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

   at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere) in /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs:line 1740
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) in /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs:line 875
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission) in /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs:line 757
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey) in /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs:line 258
   at System.Configuration.Configuration.GetSection(String sectionName) in /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/Configuration.cs:line 168
   at System.Configuration.ClientSettingsStore.GetConfigSection(Configuration config, String sectionName, Boolean declare) in /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/ClientSettingsStore.cs:line 43
   at System.Configuration.ClientSettingsStore.RevertToParent(String sectionName, Boolean isRoaming) in /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/ClientSettingsStore.cs:line 163
   at System.Configuration.LocalFileSettingsProvider.Reset(SettingsContext context) in /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/LocalFileSettingsProvider.cs:line 232
   at System.Configuration.ApplicationSettingsBase.Reset() in /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs:line 371
   at System.ConfigurationTests.ApplicationSettingsBaseTests.Save_SimpleSettings_Ok(Boolean isSynchronized) in /_/src/System.Configuration.ConfigurationManager/tests/System/Configuration/ApplicationSettingsBaseTests.cs:line 113
----- Inner Stack Trace -----
   at System.Configuration.TypeUtil.GetType(IInternalConfigHost host, String typeString, Boolean throwOnError) in /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/TypeUtil.cs:line 132
   at System.Configuration.MgmtConfigurationRecord.CreateSectionFactory(FactoryRecord factoryRecord) in /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs:line 128
   at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere) in /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs:line 1735
ViktorHofer commented 5 years ago

@maryamariyan, @safern

bartonjs commented 5 years ago

Failed on Windows7 and Windows8.1 with perhaps a new kind of error.

https://dev.azure.com/dnceng/public/_build/results?buildId=368747&view=ms.vss-test-web.build-test-results-tab&runId=11204916&resultId=100515&paneView=debug

System.ConfigurationTests.ApplicationSettingsBaseTests.Save_SimpleSettings_Ok(isSynchronized: True) [FAIL]
      System.Configuration.ConfigurationErrorsException : An error occurred creating the configuration section handler for userSettings/System.ConfigurationTests.ApplicationSettingsBaseTests_x002B_PersistedSimpleSettings: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. (C:\Users\runner\AppData\Local\Microsoft_Corporation\xunit.console_StrongName_vmuqnj1rm2vzmtjlxpznjgrpuvgx0hav\2.5.1.0\user.config line 5)
      ---- System.IO.FileNotFoundException : Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
      Stack Trace:
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs(1740,0): at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs(875,0): at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs(757,0): at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs(258,0): at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/Configuration.cs(168,0): at System.Configuration.Configuration.GetSection(String sectionName)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/ClientSettingsStore.cs(43,0): at System.Configuration.ClientSettingsStore.GetConfigSection(Configuration config, String sectionName, Boolean declare)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/ClientSettingsStore.cs(163,0): at System.Configuration.ClientSettingsStore.RevertToParent(String sectionName, Boolean isRoaming)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/LocalFileSettingsProvider.cs(232,0): at System.Configuration.LocalFileSettingsProvider.Reset(SettingsContext context)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs(371,0): at System.Configuration.ApplicationSettingsBase.Reset()
        /_/src/System.Configuration.ConfigurationManager/tests/System/Configuration/ApplicationSettingsBaseTests.cs(113,0): at System.ConfigurationTests.ApplicationSettingsBaseTests.Save_SimpleSettings_Ok(Boolean isSynchronized)
        ----- Inner Stack Trace -----
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/TypeUtil.cs(133,0): at System.Configuration.TypeUtil.GetType(IInternalConfigHost host, String typeString, Boolean throwOnError)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs(128,0): at System.Configuration.MgmtConfigurationRecord.CreateSectionFactory(FactoryRecord factoryRecord)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs(1735,0): at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)
    System.ConfigurationTests.ApplicationSettingsBaseTests.Save_SimpleSettings_Ok(isSynchronized: False) [FAIL]
      System.Configuration.ConfigurationErrorsException : An error occurred creating the configuration section handler for userSettings/System.ConfigurationTests.ApplicationSettingsBaseTests_x002B_PersistedSimpleSettings: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. (C:\Users\runner\AppData\Local\Microsoft_Corporation\xunit.console_StrongName_vmuqnj1rm2vzmtjlxpznjgrpuvgx0hav\2.5.1.0\user.config line 5)
      ---- System.IO.FileNotFoundException : Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
      Stack Trace:
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs(1740,0): at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs(875,0): at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs(757,0): at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs(258,0): at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/Configuration.cs(168,0): at System.Configuration.Configuration.GetSection(String sectionName)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/ClientSettingsStore.cs(43,0): at System.Configuration.ClientSettingsStore.GetConfigSection(Configuration config, String sectionName, Boolean declare)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/ClientSettingsStore.cs(163,0): at System.Configuration.ClientSettingsStore.RevertToParent(String sectionName, Boolean isRoaming)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/LocalFileSettingsProvider.cs(232,0): at System.Configuration.LocalFileSettingsProvider.Reset(SettingsContext context)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs(371,0): at System.Configuration.ApplicationSettingsBase.Reset()
        /_/src/System.Configuration.ConfigurationManager/tests/System/Configuration/ApplicationSettingsBaseTests.cs(113,0): at System.ConfigurationTests.ApplicationSettingsBaseTests.Save_SimpleSettings_Ok(Boolean isSynchronized)
        ----- Inner Stack Trace -----
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/TypeUtil.cs(133,0): at System.Configuration.TypeUtil.GetType(IInternalConfigHost host, String typeString, Boolean throwOnError)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs(128,0): at System.Configuration.MgmtConfigurationRecord.CreateSectionFactory(FactoryRecord factoryRecord)
        /_/src/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs(1735,0): at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)
JeremyKuhne commented 4 years ago

This is always failing trying to find System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51. The failure happens in Type.GetType It is a bit bizarre that we can't find our own assembly. Might be a version stamping issue.

I'm working on adding more logging here and changing the re-throw to retain context.

JeremyKuhne commented 4 years ago

The assembly qualified name gets serialized in the user settings, which is placed in a location that is based off of the executing assembly name and the location of the assembly. This file is persisted in the app data directory and thus will persist across test runs. What likely happened is that a run with 4.0.3.0 was followed by a run with a lower version number (the one that failed). The type requests will normally roll forward to newer versions, but never backwards to older ones.

If we find rolling forward to be a customer problem we could consider redirecting our type requests for System.Configuration types forward in TypeUtil.GetImplicitType. I don't think this will ultimately be necessary, but that would be the place to make the change.

In the immediate we need to re-enable the test. I'm going to try and:

  1. Improve the throw so we don't lose the stack.
  2. Change the test to wipe the existing user settings.
  3. Write a specific test that checks rolling forward/backward behavior.

I'll also look to see what other user settings gaps we currently have. I've done some manual testing (in the context of a Windows Forms app) and things seem to be in good shape.

cc: @maryamariyan; @ericstj

ericstj commented 4 years ago

Do we need to support cross-targeting betweek desktop and core here? Would it make sense to write the desktop identity? We've done this elsewhere, either explicitly, or by reading the TypeForwardedFrom attribute.

JeremyKuhne commented 4 years ago

Do we need to support cross-targeting betweek desktop and core here? Would it make sense to write the desktop identity? We've done this elsewhere, either explicitly, or by reading the TypeForwardedFrom attribute.

I don't think so as user settings are app location specific. I don't see a scenario where you would swap .NET Core and .NET Framework apps in the same physical location.

JeremyKuhne commented 4 years ago

There are actually two issues here. It fails consistently on Unix. Here is the current stack:

System.Configuration.ConfigurationErrorsException : Failed to save settings: An error occurred loading a configuration file: An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.\n---- System.Configuration.ConfigurationErrorsException : An error occurred loading a configuration file: An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.\n-------- System.InvalidOperationException : An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.

   at System.Configuration.ClientSettingsStore.WriteSettings(String sectionName, Boolean isRoaming, IDictionary newSettings) in /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientSettingsStore.cs:line 209
   at System.Configuration.LocalFileSettingsProvider.SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection values) in /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/LocalFileSettingsProvider.cs:line 218
   at System.Configuration.SettingsBase.SaveCore() in /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsBase.cs:line 141
   at System.Configuration.SettingsBase.Save() in /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsBase.cs:line 120
   at System.Configuration.ApplicationSettingsBase.Save() in /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs:line 389
   at System.ConfigurationTests.ApplicationSettingsBaseTests.Save_SimpleSettings_Ok(Boolean isSynchronized) in /_/src/libraries/System.Configuration.ConfigurationManager/tests/System/Configuration/ApplicationSettingsBaseTests.cs:line 122
----- Inner Stack Trace -----
   at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll) in /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs:line 1098
   at System.Configuration.Configuration.SaveAsImpl(String filename, ConfigurationSaveMode saveMode, Boolean forceSaveAll) in /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Configuration.cs:line 217
   at System.Configuration.Configuration.Save() in /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Configuration.cs:line 182
   at System.Configuration.ClientSettingsStore.WriteSettings(String sectionName, Boolean isRoaming, IDictionary newSettings) in /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientSettingsStore.cs:line 204
----- Inner Stack Trace -----
   at System.Configuration.ClientConfigurationHost.OpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext) in /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigurationHost.cs:line 312
   at System.Configuration.ClientSettingsStore.ClientSettingsConfigurationHost.OpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext) in /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientSettingsStore.cs:line 315
   at System.Configuration.UpdateConfigHost.OpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext) in /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/UpdateConfigHost.cs:line 94
   at System.Configuration.Internal.DelegatingConfigHost.OpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext) in /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Internal/DelegatingConfigHost.cs:line 96
   at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll) in /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs:line 1062

The first thing I would look at is if the app data folder exists and there are appropriate rights.

danmoseley commented 4 years ago

Was going to move this out but I don't have enough context.

ericstj commented 4 years ago

Not seeing a regression here. It'd be nice to fix this but I don't see that meeting the bar for 5.0 and this existed in 3.x as well.

trysil commented 3 years ago

If that helps, I get the same exception on Linux when trying to save/upgrade settings and the "/home/USERNAME/.local/share" directory does not exist. This is the location where configuration file should be stored.

Configuration file path is empty, when the parent directory does not exist. It's easy to check its value with this code:

ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath

This behavior is confirmed in documentation for Environment.GetFolderPath():

The path to the specified system special folder, if that folder physically exists on your computer; otherwise, an empty string ("").

(https://docs.microsoft.com/en-us/dotnet/api/system.environment.getfolderpath?view=net-5.0)

I found two possible solutions:

  1. Manually create the directory tree.
  2. Ensure in code that the LocalApplicationData folder exists by using SpecialFolderOption.Create parameter:
    string localAppData = Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData, System.Environment.SpecialFolderOption.Create);

In my opinion, the stacktrace from saving application settings gives no clue, that the problem is with non-existing folder. This could be definetely improved. It took couple of days to figure this out and I suppose this is the reason for errors in your unit tests.

Stacktrace:

Unhandled exception. System.Configuration.ConfigurationErrorsException: Failed to save settings: An error occurred loading a configuration file: An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.
 ---> System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.
 ---> System.InvalidOperationException: An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.
   at System.Configuration.ClientConfigurationHost.OpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext)
   at System.Configuration.ClientSettingsStore.ClientSettingsConfigurationHost.OpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext)
   at System.Configuration.UpdateConfigHost.OpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext)
   at System.Configuration.Internal.DelegatingConfigHost.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 System.Configuration.ClientSettingsStore.WriteSettings(String sectionName, Boolean isRoaming, IDictionary newSettings)
   --- End of inner exception stack trace ---
   at System.Configuration.ClientSettingsStore.WriteSettings(String sectionName, Boolean isRoaming, IDictionary newSettings)
   at System.Configuration.LocalFileSettingsProvider.SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection values)
   at System.Configuration.SettingsBase.SaveCore()
   at System.Configuration.SettingsBase.Save()
   at System.Configuration.ApplicationSettingsBase.Save()
   at ConfigFileApp.Program.Main(String[] args)
danmoseley commented 3 years ago

Thank you @trysil for the investigation. Do you have any interest in offering a proposed PR?

ARMoir commented 3 years ago

Windows 10 I had to add the following to save Settings on Linux

Directory.CreateDirectory(Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData, System.Environment.SpecialFolderOption.Create));