Open KlausLoeffelmann opened 5 years ago
@dmonroym @davidwengier What's the status of this bug?
We thought this was the same bug as was previously fixed with the resource editor (and I thought this issue was already closed), and that the issue was simply that the project had been created before that fix went in. With the repro in https://github.com/dotnet/winforms-designer/issues/1119 I can see now this is a separate issue of two systems not agreeing with each other.
The winforms designer has its own TypeNameConverter
function here which obviously doesn't have the workaround we put in for #5589. This isn't a problem for the winforms designer as it runs in .NET Core. With this repro though, the bug occurs when opening a .resx file written by the .NET Core winforms designer, in the .NET Framework resource designer.
We should see if we can have the resource editor map the .NET Core types back to .NET Framework types when reading in the resource file, which is similar to what it used to do when writing the file (and maybe even did, before I removed that code? ¯\_(ツ)_/¯)
The long term fix for this will be https://github.com/dotnet/winforms-designer/issues/236
@KlausLoeffelmann you could potentially update the winforms designer with the same workaround as in the VS change that fixed the resource editor, or even possibly somehow remote the MultiTargetService from VS and use it directly? That way at least we wouldn't be maintaining two allowlists of types.
@dmonroym we can talk about this tomorrow.
The MultiTargetService.cs which you referred to we no longer in use. (So isn't any of the code which is in the Legacy folder.) We keep that code there for now only for easier lookup purposes. Also, I am not sure why the long term fix for this will be https://github.com/dotnet/winforms-designer/issues/236. That issue just referrs to the Winforms Designer part of the Resource Editor (so, the actual Type Editor which adds an Image Resource for example), but it does not refer to any functionality of the project system. (I'd agree though, we'd need a better description or a better title to describe the scope):
Let me see, what options we have. The serialization is completely done in Core - VS just gets the complete resource content and the CodeDom back, so, I need to understand what the options are.
I may have misinterpreted what that issue is, but I think the long term fix for this issue is a .NET Core Resource Editor that is OOP and remoted into VS much like the WinForms Designer.
Yes, I think so too. But I may have a quick and dirty solution for now. I keep you posted.
@KlausLoeffelmann: Any update here? It sounds to me like the adding the same hack to the classic designer code base is the way to make this work in the short term.
Verified this issue on VS latest build: 16.9.0 Preview 3.0 [30820.7.main], the error is changed after double-click on Form3.resx, details please see the following screenshot:
@KlausLoeffelmann: I ran into the same problem migrating several WinForms apps from .NET Framework 4.6 to .NET 5 (https://developercommunity.visualstudio.com/content/problem/1311830/resx-file-corrupted-after-migration-to-net-5.html). Hence the question of whether and when a solution or a workaround can be expected?
We started (VS 16.10) writing Framework types into resx file for Core projects wherever "TypeForwardedFrom" attribute available. And for types that are not available in desktop framework or missing this attribute, we will be writing types by stripping the binary version number. This may not solve the issue completely but the noise will be reduced until we introduce core only types.
I hope this output from "ResX Resource Manager" can help in your investigation. I get this when I change from some Language
property to the (Default).
Error: System.InvalidOperationException: Collection was modified; enumeration operation may not execute. at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) at System.Collections.Generic.Dictionary2.KeyCollection.Enumerator.MoveNext() at ResXManager.Model.ResourceEntity.UpdateChangedEntries(IDictionary2 targets, IDictionary2 sources) in D:\a\1\s\src\ResXManager.Model\ResourceEntity.cs:line 320 at ResXManager.Model.ResourceEntity.MergeItems(IDictionary2 targets, IDictionary2 sources) in D:\a\1\s\src\ResXManager.Model\ResourceEntity.cs:line 293 at ResXManager.Model.ResourceEntity.Update(ICollection1 files, CultureInfo neutralResourcesLanguage, DuplicateKeyHandling duplicateKeyHandling) in D:\a\1\s\src\ResXManager.Model\ResourceEntity.cs:line 52 at ResXManager.Model.ResourceManager.<>c__DisplayClass51_0.b3(Boolean current, Tuple2 item) in D:\a\1\s\src\ResXManager.Model\ResourceManager.cs:line 245 at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable1 source, TAccumulate seed, Func`3 func) at ResXManager.Model.ResourceManager.d51.MoveNext() in D:\a\1\s\src\ResXManager.Model\ResourceManager.cs:line 245 — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at ResXManager.Model.ResourceManager.d50.MoveNext() in D:\a\1\s\src\ResXManager.Model\ResourceManager.cs:line 149 — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at ResXManager.Model.ResourceManager.d23.MoveNext() in D:\a\1\s\src\ResXManager.Model\ResourceManager.cs:line 66 — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at ResXManager.Model.ResourceManager.d47.MoveNext() in D:\a\1\s\src\ResXManager.Model\ResourceManager.cs:line 125 — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at ResXManager.View.Visuals.ResourceViewModel.d94.MoveNext() in D:\a\1\s\src\ResXManager.View\Visuals\ResourceViewModel.cs:line 517
@BDisp This looks related to this extension: https://marketplace.visualstudio.com/items?itemName=TomEnglert.ResXManager. Can you disable the extension and see if that resolves it?
Thanks for your feedback @davkean . I only posted this exception to help find out why the the exception "System.NotSupportedException: Cannot read resources that depend on serialization.", is triggered when attempting to run the WinForm application. The only tool I can use to open the resx's files is the "ResXManager". Even removing or disabling this tool I can't run the my application due the serialization exception.
When we set the Localizable
property to true and adding, removing or changing controls and components... looks like the resx's files became corrupted or invalid. Please see here https://developercommunity.visualstudio.com/t/resx-file-corrupted-after-migration-to-net-5/1311830. It also happens with .Net Core 3.1.
I discovered what happens here. In all resx
files, with the exception of neutral resx
, I removed all data that were not translated with the exception of location and size data. In a small example and only to be easier to test, I used a HelpProvider
and Tooltip
component with 2 Label
and 2 TextBox
. The nodes of these components that have not been translated but generated in the resx
files is that they were causing this error. However, I understand that it is not easy to handle all the implications that all types can cause when generating the files. Thank you for your magnificent work.
I've stumbled upon the same or at least a similar problem when migrating a .NET Framework project to .NET 5.
I have a localizable Form where a TooltipText property of a custom control is not set.
With .NET Framework the designer creates the following entry in the neutral resx file:
<data name="treeColumnDescr.TooltipText" type="System.Resources.ResXNullRef, System.Windows.Forms">
<value />
</data>
When using .NET 5 the designer creates the following instead, which not only breaks opening the resx resource editor, but more importantly an exception occurs when InitializeComponent is executed at runtime:
<assembly alias="Microsoft.DotNet.DesignTools.Server" name="Microsoft.DotNet.DesignTools.Server, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<data name="treeColumnDescr.TooltipText" type="Microsoft.DotNet.DesignTools.Utilities.Resources.ResXNullRef, Microsoft.DotNet.DesignTools.Server">
<value />
</data>
In Visual Studio 16.10 I can view the form in the designer alright, but when starting the application in net472 after the resx has been changed I still get the same error as described by deng0. Works fine with net5-windows or with net472 and Localizable=false.
System.NotSupportedException: 'Cannot read resources that depend on serialization.'
at System.Resources.Extensions.DeserializingResourceReader.FindType(Int32 typeIndex)
at System.Resources.Extensions.DeserializingResourceReader.DeserializeObject(Int32 typeIndex)
at System.Resources.Extensions.DeserializingResourceReader.LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.Extensions.DeserializingResourceReader.ResourceEnumerator.get_Entry()
at System.Resources.Extensions.DeserializingResourceReader.ResourceEnumerator.get_Current()
at System.ComponentModel.ComponentResourceManager.FillResources(CultureInfo culture, ResourceSet& resourceSet)
at System.ComponentModel.ComponentResourceManager.FillResources(CultureInfo culture, ResourceSet& resourceSet)
at System.ComponentModel.ComponentResourceManager.FillResources(CultureInfo culture, ResourceSet& resourceSet)
at System.ComponentModel.ComponentResourceManager.ApplyResources(Object value, String objectName, CultureInfo culture)
at AMANA.XBRL.Engine.Editor.LinkbasesAndDetailsForm.InitializeComponent() in
I have this issue in VS 2022.
`Microsoft Visual Studio Community 2022 Version 17.1.0 VisualStudio.17.Release/17.1.0+32210.238 Microsoft .NET Framework Version 4.8.03761
Installed Version: Community
Visual C++ 2022 00482-90000-00000-AA783 Microsoft Visual C++ 2022
.NET Core Debugging with WSL 1.0 .NET Core Debugging with WSL
ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools
ASA Service Provider 1.0
ASP.NET and Web Tools 2019 17.1.358.51495 ASP.NET and Web Tools 2019
ASP.NET Web Frameworks and Tools 2019 17.1.358.51495 For additional information, visit https://www.asp.net/
Azure App Service Tools v3.0.0 17.1.358.51495 Azure App Service Tools v3.0.0
Azure Data Lake Tools for Visual Studio 2.6.5000.0 Microsoft Azure Data Lake Tools for Visual Studio
Azure Functions and Web Jobs Tools 17.1.358.51495 Azure Functions and Web Jobs Tools
Azure Stream Analytics Tools for Visual Studio 2.6.5000.0 Microsoft Azure Stream Analytics Tools for Visual Studio
C# Tools 4.1.0-5.22109.6+0c82c4114a4e4b8b723b915eee3b13261db6717f C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
DevExpress Reporting Extension 1.4 A Visual Studio extension that invokes the Report Designer editor for report definition VSREPX files.
DevExpress Reporting Tools Extension 1.0 Extends Visual Studio with tools required for the Report Designer editor.
DevExpress.DeploymentTool 1.0 A useful tool for deploying DevExpress assemblies.
DevExpress.Win.LayoutAssistant Extension 1.0 DevExpress.Win.LayoutAssistant Visual Studio Extension Detailed Info
Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events
Microsoft Azure Hive Query Language Service 2.6.5000.0 Language service for Hive query
Microsoft Azure Service Fabric Tools for Visual Studio 17.0 Microsoft Azure Service Fabric Tools for Visual Studio
Microsoft Azure Stream Analytics Language Service 2.6.5000.0 Language service for Azure Stream Analytics
Microsoft Azure Tools for Visual Studio 2.9 Support for Azure Cloud Services projects
Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft Library Manager 2.1.161+abc97ecc7d.RR Install client-side libraries easily to any web project
Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards
Microsoft Visual Studio Tools for Containers 1.2 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.
Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package
NuGet Package Manager 6.1.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Razor (ASP.NET Core) 17.0.0.2206201+62a2c1d6162f828801565a7ca26d9d48b810a05b Provides languages services for ASP.NET Core Razor.
SQL Server Data Tools 17.0.62201.12090 Microsoft SQL Server Data Tools
ToolWindowHostedEditor 1.0 Hosting json editor into a tool window
TypeScript Tools 17.0.1229.2001 TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 4.1.0-5.22109.6+0c82c4114a4e4b8b723b915eee3b13261db6717f Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 17.1.0-beta.21610.4+07b5673e4f2fa7630e78abe37f16b372353a7242 Microsoft Visual F# Tools
Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
Visual Studio Container Tools Extensions 1.0 View, manage, and diagnose containers within Visual Studio.
Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio.
Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers`
Visual Studio Version: Visual Studio 2019 >=16.5.0 Preview 1.0. (The necessary Core-Designer ResourcePicker feature has not been merged at the time of creating this issue, though - see Steps to Reproduce).
Summary: With the WinForms Core Designer, local resource files (later also project resource files) for Forms or UserControls are added, whose images content is not created by the runtime but by the out-of-proc Designer Surface Process. The images that end up in the resource files are thus based on the corresponding .NET Core type and cannot be displayed by the Managed Resource Editor.
Steps to Reproduce: Since the feature is not yet publicly available in the Visual Studio previews, the easiest way to repro is to use the attached sample project to track the bug.
ManResourceEditorRepro.zip
Expected Behavior: The Managed Resource Editor should show the image content of the resource file.
Actual Behavior: The Manage Resource Editor shows this.
User Impact: Users can neither show or edit Images, which have been added to the resource files via the .NET Core WinForms designer.