Repository navigation
Reading application settings in NET WinForms OOP designer fails with exception 'Invalid URI: The hostname could not be parsed" #70318
Description
Activity
- addeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on May 27, 2022 The application settings are resolved in the context of the currently running app - which in the case of the out-of-proc designer is DesignToolsServer.dll.
Here's what's going on here. When we're trying to resolve
Properties.Settings.HelloWorld, the .NET runtime is trying to locate the DesignToolsServer's settings and it fails here:System.Private.Uri.dll!System.Uri.Uri(string uriString) System.Configuration.ConfigurationManager.dll!System.Configuration.ClientConfigPaths.ClientConfigPaths(string exePath = null, bool includeUserConfig) Line 77 at /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigPaths.cs(77) System.Configuration.ConfigurationManager.dll!System.Configuration.ClientConfigPaths.GetPaths(string exePath, bool includeUserConfig = true) Line 212 at /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigPaths.cs(212) System.Configuration.ConfigurationManager.dll!System.Configuration.Internal.ConfigurationManagerInternal.System.Configuration.Internal.IConfigurationManagerInternal.ExeProductName.get() Line 19 at /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Internal/ConfigurationManagerInternal.cs(19) System.Configuration.ConfigurationManager.dll!System.Configuration.ApplicationSettingsBase.Initializer.get() Line 678 at /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs(678) System.Configuration.ConfigurationManager.dll!System.Configuration.ApplicationSettingsBase.CreateSetting(System.Reflection.PropertyInfo propertyInfo = {System.Reflection.RuntimePropertyInfo}) Line 459 at /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs(459) System.Configuration.ConfigurationManager.dll!System.Configuration.ApplicationSettingsBase.EnsureInitialized() Line 584 at /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs(584) System.Configuration.ConfigurationManager.dll!System.Configuration.ApplicationSettingsBase.Properties.get() Line 140 at /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs(140) System.Configuration.ConfigurationManager.dll!System.Configuration.SettingsBase.GetPropertyValueByName(string propertyName = "HelloWorld") Line 55 at /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsBase.cs(55) System.Configuration.ConfigurationManager.dll!System.Configuration.SettingsBase.this[string].get(string propertyName) Line 29 at /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsBase.cs(29) System.Configuration.ConfigurationManager.dll!System.Configuration.ApplicationSettingsBase.GetPropertyValue(string propertyName = "HelloWorld") Line 731 at /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs(731) System.Configuration.ConfigurationManager.dll!System.Configuration.ApplicationSettingsBase.this[string].get(string propertyName) Line 403 at /_/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs(403) MyButtonLibrary.dll!MyButtonLibrary.Properties.Settings.HelloWorld.get() MyButtonLibrary.dll!MyButtonLibrary.MyButton.ApplicationSettingsTest() MyButtonLibrary.Design.dll!MyButtonLibrary.Design.MyButtonActionList.ApplicationSettingsBug()The issue here is that the designer is located at a path similar to
\\?\C:\Users\user\AppData\Local\Microsoft\VisualStudio\17.0_dfbd86c6Exp\WinFormsDesigner\figs3bhx.mvu\andUriis unable to handle\\?paths. This was fixed in #56897 for .NET 7, however, it doesn't appear the change was complete as .NET 7 still fails with the same error, though at a different point:

/cc: @krwq @jeffhandleyRepro Steps:
1. Create a Winforms .NET Core 6.0 application
2. Download and copy "MyButtonLibrary.1.0.102.nupkg" from "\Pack\packages\MyButtonLibrary.1.0.102.nupkg" to "C:\Program Files (x86)\Microsoft SDKs\NuGetPackages"
3. Right click the project and select " Manguage NuGet Packages…"
4. The Package source select All and switch Installed to Browse
5. Search and install "MyButtonLibrary"
6. Switch to Form designer, drag and drop MyButton control onto Form1
7. Right click control and select "Change button text using application setting - This FAILS"Actual Result:
The exception pops up.


Expected Result:
No exception pops up.Do you have an ETA when this might be fixed? This issue has blocked us from adding design-time support for our NET6 WinForms control. We can't release until this is fixed.
Thanks.@jeffhandley @krwq putting this on your radar.
Thanks for the clear repro @tracktownsoftware and the additional details @RussKie as you pointed out the issue caused by the AppDomain.CurrentDomain.BaseDirectory path prefixed with
\\?\when creating Uri at:
Line 251 in c8654e7
Uri codeBase = new Uri(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, assembly.ManifestModule.Name));
I could be able to fix this by removing the prefix if exist or something like that, but it seems better to be fixed at the Uri constructor or AppDomain.CurrentDomain.BaseDirectory level as @jkotas suggested in previous PR so that we will not see similar issues again. One of the issues even closed, so I would suggest you to go to those issues and ask for urgent fix- removeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Jun 14, 2022 @karelz this is a core scenario for the Windows Forms designer
16 remaining items
Could you give me a hand and point me a release that I can test? I've downloaded the latest nightly (7.0.100-preview.7.22329.1) from dotnet/installer, and it only contains the runtime build from 15 June (7.0.0-preview.6.22314.11+eeb0c1551b5fc9ccd6ceeaf5d2b1504afab249d7), and the fix was merged on 23 June.
Thank youI am afraid this won't work. The daily build contains only Microsoft.NETCore.App workload, and the fix went into System.Configuration.ConfigurationManager.dll, which is a part of Microsoft.WindowsDesktop.App workload.
You should be able to get daily build of the System.Configuration.ConfigurationManager.dll package using the instructions at the top of the document.
Could you give me a hand and point me a release that I can test?
In addition to what @jkotas suggestion I also sent you email with
System.Configuration.ConfigurationManager.6.0.1.nupkgpackage built from 6.0 branch with the fixes@RussKie please let us know your test result so that we can complete the servicing request
Thank you @buyaa-n.
I installed 7.0.100-rc.1.22371.1 available at https://github.com/dotnet/installer, and tested the repro provided in https://github.com/tracktownsoftware/MicrosoftWinFormsDesignerSDK_AppSettingsBug. I created a Windows Forms app targeting .NET 7 and referenced the built NuGet from the repro project.
The issue is fixed:
70318.mp4
Reacted by Buyaa NamnanI have also retested the repro from #56897 (comment), and it also appears to be fixed by this.
🎉
- ghost addedin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
on Jul 22, 2022 Thanks @RussKie, updated the servicing PR description as needed, will send out servicing request email on Monday
- ghost removedin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
on Aug 11, 2022 - ghost locked as resolved and limited conversation to collaborators
on Sep 14, 2022
Environment
Version 17.2.2
.NET version
net6.0-windows
Did this work in a previous version of Visual Studio and/or previous .NET release?
No, this is new in VS2022 and the NET WinForms OOP designer.
Issue description
This is an issue in the new NET WinForms designer when using the microsoft.winforms.designer.sdk to add design-time support to a custom NET6 WinForms control. Reading application settings at design-time fails with exception “Invalid URI: this hostname could not be parsed”.
I also reported this as feedback from VS2022:
https://developercommunity.visualstudio.com/t/Reading-application-settings-fails-in-th/10055004
Steps to reproduce
My github sample to reproduce:
https://github.com/tracktownsoftware/MicrosoftWinFormsDesignerSDK_AppSettingsBug
The above repository includes a Nuget package you can use to test and reproduce. The nuget package contains a custom NET6 WinForms "MyButton" control with WinForms Designer Extensibility SDK design-time support.
Diagnostics
No response