Converting .NET customizations
How to migrate backend code (.cs files) from .NET Framework to .NET8
When it comes to converting .NET customizations, this is the at-a-glance view of extensibility point compatibility between DW9 and DW10:
Extensibility point | Compatibility |
---|---|
Notifications | 95% |
Providers (e.g. PriceProvider, ProductIndexSchemaExtender, CheckoutHandler) | 100% |
Content modules (ContentModule) and settings (ContentModules_Edit.aspx) | 100%/0% |
DynamicWeb API | 85% |
Dynamicweb.Ecommerce API | 90% |
DynamicWeb Modules API (Forms, Datalist, etc.) | 99% |
DynamicWeb Core APIs (Caching, Database, Logging, etc.) | 95% |
The following extensibility points are obsolete and must be replaced:
Extensibility point | Reason | Replacement |
---|---|---|
UI Extensibility (Ribbonbar, Dashboard, Statistics, etc.) | Dependent on DW9 UI | New UI Extensibility |
Item type editors (Items) | Dependent on DW9 UI | New UI Extensibility |
FieldTypeProviders | Dependent on DW9 UI | New UI Extensibility |
Pipeline-dependent notifications (Dynamicweb.Notifications.Standard.Application) | .NET 4 runtime related | IPipeline and Middleware |
Web.config | .NET 4 runtime related | IPipeline and Middleware |
Global.asax and Default.aspx | .NET 4 runtime related | IPipeline and Middleware |
Upgrading from NET4.X to NET8 projects
There are several strategies for migrating C# code to NET8, many of which can be read on, for instance, in official Microsoft docs. A quick and effective strategy is simply creating new NET8 projects (.csproj style) for each legacy project in the solution - and copy the code, one or more files at a time.
This strategy will work especially well for smaller projects:
- Change project to .NET 8
- Remove usage of system.web - replace with Dynamicweb.Context
- Isolate or delete incompatible code
- Change to use PackageReference format for C# projects
- Update nuget dependencies to latest 9.15 or 10.X.X packages
- Remove all usage of deprecated DynamicWeb APIs
- Remove all usage of deprecated .NET APIs
- Remove unused dependencies
Changing the project to .NET Standard/.NET 8
There are two ways to change you project to .NET Standard or .NET 8:
- Create a new project (RECOMMENDED)
- Open the folder with the current project in VS Code
- Rename .csproj to .csproj.old
- Open a terminal in the project folder
- Create a new project 'dotnet new classlib -f netstandard2.1'
- Add required packages
- dotnet add package dynamicweb
- dotnet add package dynamicweb.ecommerce
- Build the project - 'dotnet build'
- Use the .NET Upgrade Assistant
- Go to the .NET Upgrade Assistant page
- Follow the guide
As soon as your project builds and runs on DynamicWeb 10, you should change the project to .NET 8 instead of .NET Standard.