-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reading application settings in NET WinForms OOP designer fails with exception 'Invalid URI: The hostname could not be parsed" #70318
Comments
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
The issue here is that the designer is located at a path similar to |
Repro Steps: Actual Result: Expected Result: |
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. |
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
@jeffhandley @krwq putting this on your radar. |
Tagging subscribers to this area: @dotnet/area-system-configuration Issue DetailsEnvironmentVersion 17.2.2 .NET versionnet6.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 descriptionThis 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: Steps to reproduceMy github sample to reproduce: 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. DiagnosticsNo response
|
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 Line 251 in c8654e7
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 |
@karelz this is a core scenario for the Windows Forms designer |
Another workaround could be move the Uri creation code Line 251 in c8654e7
to the location where it is used: Line 269 in c8654e7
This workaround at least works for the repro attached |
I just answered on the other issue - #58712 (comment), trying to explain the context and limitations we are facing in the Who can help us better understand the details of the above scenario of |
I agree with @karelz that fixing anything in Uri is complex and has very high risks. It does not make sense to push to address this in Uri for .NET 7. It would be a new feature and it may require new APIs. There are cheaper and lower risk options to address the specific WinForms issue. We should look at those: Workaround it in the System.Configuration.ConfigurationManager library itself, or fix #58714 |
Compatibility with .NET Framework. The original .NET Framework code is here: https://github.com/microsoft/referencesource/blob/5697c29004a34d80acdaf5742d7e699022c64ecd/System.Configuration/System/Configuration/ClientConfigPaths.cs#L343-L411 . Notice that it does not use the problematic Uri constructor. This is trying to mimic .NET Framework logic that was based on Code Access Security. It looks like that this logic deviated over time from .NET Framework one through series of bug fixes, so it does not fully match what .NET Framework did anyway. Another option to address the WinForms issues is to delete the part of the logic that tries to use Uris. It may be an observable behavior change, but I doubt that anybody will notice. |
Looked up for all Uri creation within the Lines 90 to 92 in c8654e7
I will move the that case as I mentioned here and probably use Uri.TryCreate() instead of using ctor |
Looks like the discussion has split between here and #58712. And since the latter is closed, in attempt to merge the forks, @karelz I'm going to reply to your questions here:
In .NET Framework the Windows Forms designer is run in the VS process (as both the host and the designer use the same runtime). To facilitate the .NET support the designer was moved out-of-proc, and the server process is started with
There aren't any workarounds we can do in the designer AFAIK - as this is purely a .NET runtime scenario. I first reported at almost a year ago in #56897. It is worth noting, that the Windows Forms out-of-process designer codebase is targeting .NET Core 3.1 so that our customers can design .NET Windows Forms apps targeting .NET Core 3.1 and above. With .NET Core 3.1 starting to near its EOL there's no appetite to get this fixed in it, but we'd want the fix to be serviced in to .NET 6, as this bug is blocking the adoption (e.g., this one or #56897). |
@RussKie the fix merged to preview 6, hope you could dogfood from there and test the WinForms designer scenarios It fixes the repro attached to the issue, I don't see any other Uri creation logic that could cause similar issue within |
Tagging @ericstj @jeffhandley for considering porting to .NET 6, |
Thank you @buyaa-n for the fix. I'll give it a try once it flows through to dotnet/winforms. |
Can folks familiar with the bug and fix consider the servicing bug bar to see if they'd like to make the case to fix in .NET 6.0 servicing? If so, then the next steps would be to prepare such a PR and apply the template. |
In our area pod triage we discussed this and decided to move forward with servicing request, the bot created the porting PR but I just found that 6.0 branch doesn't have the previous fix @krwq did, without that the fix is incomplete, not sure what we do in such case, I could cherry-pick the @krwq's change into the PR. Further I am planning to build the 6.0 porting branch and give the binaries to @RussKie so that he test with their scenario before requesting for servicing. |
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. |
I 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. |
In addition to what @jkotas suggestion I also sent you email with |
@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 |
I have also retested the repro from #56897 (comment), and it also appears to be fixed by this. 🎉 |
Thanks @RussKie, updated the servicing PR description as needed, will send out servicing request email on Monday |
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
The text was updated successfully, but these errors were encountered: