Search code examples
c#.netwindows-xplegacylegacy-code

.NET 4.0 compiled application attempts to load .NET 4.8 framework


I have a legacy WPF application where I had to do some adjustments and which must be compiled to .NET 4.0 (because it is running on some WinXP production machines - nicely isolated, don't worry about that) and .NET 4.8 (Win10/11). I joined the two branches and upgraded them to a solution with multi-targeting SDK projects (NET40;NET48), made sure the PDBs are still in native format and the target platform x86 - everything works fine on my machine. But on these production machines a dialog appears informing me that the application depends on .NET 4.8 and asking me whether I would like to install it (which of course is not possible - .NET 4.8 cannot be installed on WinXP). When I decompile my .NET 4.0 executable I see it really is a NET40 application and x86 compiled. Any ideas?


Solution

  • You could try to remove the sku optional attribute from the app.config file. See: https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/startup/supportedruntime-element