Open CortiWins opened 1 week ago
@LeafShi1 - could your team please investigate a workaround, I guess we can define resources in the project file explicitly instead of relying on the designer generated code.
We offer you two options
Remove namespace (.FormsTest) in Form1.cs and Form1.designer.cs
Add icon to the project. Change the code
During the last days i created a workaround for us that solves it for us for now. Doing that made me realize that my previous description of net8 including the namespace is not 100% specific.
net8 uses the namespace/formtypename net 48 uses projectname/foldername/formfilename
which leads us to two workarounds 1) making projectname, foldername and filename match exactly to namespace and typename. 2) set the form icon in code. from project ressources, from embeddedData or something else.
So as mentioned i made a workaround that works for us. So this is not a cry for help but just a plain old bug report, with a fancy image so not even that plain.
Have a nice day everyone!
This issue doesn't reproduce in separate NetFramework48 project or separate Net8 project, it only occurs when set multi target frameworks in a project <TargetFrameworks>net8.0-windows;net48</TargetFrameworks>
@Tanya-Solyanik This looks like a build issue, do we need to investigate this further?
@merriemcgaw - multitargeting an important scenario to enable migration to .NET, should we move this issue to the designer repo and investigate further?
This issue doesn't reproduce in separate NetFramework48 project or separate Net8 project, it only occurs when set multi target frameworks in a project
<TargetFrameworks>net8.0-windows;net48</TargetFrameworks>
From my tests, it is not the multitargeting. If i set the project that has the problem in multitarget to <TargetFramework>net48</TargetFramework>
instead of multitarget, the probem still exists.
A new NetFramework48 project still uses the old project file format, while the problem happens in projects with a net SDK project file.
@CortiWins - what happens when you change the .NET Framework project format to SDK style?
@CortiWins - what happens when you change the .NET Framework project format to SDK style?
Net SDK style created with 8.0, TargetFramework changed to 4.8 -> error Net Framework 4.8 Updated via the Update Wizard to 8.0, TargetFramework changed to 4.8 -> error
.NET version
Net8.0-windows, Net Framework 4.8
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
No response
Issue description
While upgrading an application to multitarget of both Net8 and classic Net48, i encountered an issue. The icon on a form, (saved as a ressource in the forms resx) did load correctly on Net8 but caused an exception on net48.
Steps to reproduce
I tried to recreate the issue in an example problem but it did not happen, so i used ILSpy to check the ressources in the assembly of the application and noticed that they do have different names between the net48 assembly and the net8 assembly, and the difference is the namespace.
This allowed me to recreate the error in the example application.( see attachment ) MultitargetRessourceProblem.zip
In ILSpy it looks like this. As you can see, Net8 includes the Namespace into the resource name, while net4 does not.
With a namespace matching the path in the project, both net48 and net8 can load the resource.