dotnet / upgrade-assistant

A tool to assist developers in upgrading .NET Framework applications to .NET 6 and beyond
MIT License
1.1k stars 163 forks source link

Getting several errors after upgradation of .Net Framework 4.8 project to .Net 6 #897

Open sunilforever opened 2 years ago

sunilforever commented 2 years ago

Hi, We have a project built in ".Net Framework 4.8" and Application Type of which is "Windows Service". We tried to upgrade that project to ".Net 6" with command "upgrade-assistant upgrade --target-tfm-support Preview MySolution.sln", it was upgraded, but when we build it, it gave us several errors for below packages missing. We tried to add these packages from NuGet, but didn't find ant of these packages.

Would someone please tell us the alternate of these packages?

System.Configuration.Install System.ServiceProcess.ServiceProcessInstaller System.ServiceProcess.ServiceInstaller System.Web.Services System.Web.Services.Protocols System.Web.Script.Serialization

Here are some of the errors we encountered after building the project.

Type 'SoapExtension' is not defined Type 'LogicalMethodInfo' is not defined Type 'SoapExtensionAttribute' is not defined Late-bound extension methods are not supported
Type 'System.Web.Script.Serialization.JavaScriptSerializer' Type 'System.Configuration.Install.Installer' is not defined
Type 'System.ServiceProcess.ServiceProcessInstaller' is not defined

mjrousos commented 2 years ago

Hi @sunilforever, these are APIs that aren't present in .NET 6, so you will need to replace them with alternatives.

For the Configuration and ServiceProcess namespaces, look at how Windows Services are installed for .NET 6 now: https://docs.microsoft.com/en-us/dotnet/core/extensions/windows-service#create-the-windows-service. Basically, the service itself is the same as always, but installation is done via sc.exe instead of via these APIs.

For the System.Web namespaces, can you give more details on the APIs you're using here? Soap web services aren't supported in .NET 6, but you can probably create similar endpoints with ASP.NET Core.

sunandabalu commented 2 years ago

We can look into adding analyzers to point to the right documentations in these scenarios.

sunilforever commented 2 years ago

We can look into adding analyzers to point to the right documentations in these scenarios.

Would you please guide me... how to add "analyzers"

sunandabalu commented 2 years ago

We can look into adding analyzers to point to the right documentations in these scenarios.

Would you please guide me... how to add "analyzers"

By analyzers we meant Roslyn Analyzers that can identify usage of these APIs and create diagnostics with next steps. Here are some useful docs on writing Roslyn Analyzers - https://github.com/dotnet/upgrade-assistant/blob/main/docs/roslyn_best_practices.md https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/ https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/tutorials/how-to-write-csharp-analyzer-code-fix

Default Analyzers in UA if you want to look at a sample- https://github.com/dotnet/upgrade-assistant/tree/main/src/extensions/default/analyzers/Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers

ApiAlertAnalyzer is an interesting one, coz you can create custom alerts on specific namespace, type or member usage - https://github.com/dotnet/upgrade-assistant/blob/main/src/extensions/default/analyzers/Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers/ApiAlertAnalyzer.cs