My company has a solution, the project is a Winforms app running on .NET Framework 4.0.
I add a new project on .NET 7.0 to the solution, and I went to use through Framework 4.0 Project execute Net 7.0 Project .
I include using the net 7.0 dll and I edit Program.cs
as follows:
Application.Run(new RunFmNet7());
I get this error:
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
I edit the config but it still is not working:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Windows.Forms" culture="neutral" publicKeyToken="b77a5c561934e089"/>
<bindingRedirect oldVersion="6.0.0.0-7.0.0.0" newVersion="7.0.0.0"/>
<codeBase version="7.0.0.0" href="bin\Debug\System.Windows.Forms.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
What can I do to make it work?
.NET has gone under a substantial renaissance. To that effect, .NET Core (and 5.0 and newer) have a new runtime that isn't compatible with the CLR in .NET Framework. You will have to migrate your old code base to the newer .NET runtime - that includes changing the project structure, identifying incompatible dependencies and rebuilding. Microsoft has extensive documentation on the subject.