Skip to main content

Port an Existing XAF Application to .NET 6

  • 4 minutes to read

Assemblies, demos, and project templates for XAF ASP.NET Core Blazor and WinForms (.NET Core) v21.1 target .NET 6 instead of .NET Standard 2.1 and .NET Core 3.0. Install Visual Studio 17.0 or higher to use .NET 6+.

This topic explains how to update your existing XAF solution to .NET 6+.

Important

Copy and save the current versions of all csproj files before porting.

Port an XAF WinForms App from .NET Framework to .NET 6

Make sure that your XAF WinForms application can be migrated to .NET 6+ and all the required components are installed on your machine. For details, refer to the following topic: .NET 6+ Support and Migration.

Follow the steps below to port the application:

  1. In the Solution Explorer, unload all projects.

  2. Replace the existing code in each csproj file with the following:

    MySolution.Module

    <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
            <TargetFramework>net6.0</TargetFramework>
            <RootNamespace>MySolution.Module</RootNamespace>
            <Deterministic>False</Deterministic>
        </PropertyGroup>
        <ItemGroup>
            <EmbeddedResource Include="**\*.svg" />
            <EmbeddedResource Include="**\*.xafml" />
            <EmbeddedResource Remove="bin\**" />
        </ItemGroup>
        <ItemGroup>
            <PackageReference Include="DevExpress.ExpressApp" Version="23.2.5" />
        </ItemGroup>
    </Project>
    

    MySolution.Module.Win

    <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
            <TargetFramework>net6.0-windows</TargetFramework>
            <Deterministic>False</Deterministic>
        </PropertyGroup>
        <ItemGroup>
            <EmbeddedResource Include="**\*.svg" />
            <EmbeddedResource Include="Model.DesignedDiffs.xafml" />
            <EmbeddedResource Remove="bin\**" />
        </ItemGroup>
        <ItemGroup>
            <ProjectReference Include="..\MySolution.Module\MySolution.Module.csproj" />
        </ItemGroup>
    </Project>
    

    MySolution.Win

    <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
            <OutputType>WinExe</OutputType>
            <TargetFramework>net6.0-windows</TargetFramework>
            <Deterministic>False</Deterministic>
        </PropertyGroup>
        <ItemGroup>
            <Content Include="Model.xafml">
                <CopyToOutputDirectory>Always</CopyToOutputDirectory>
            </Content>
            <EmbeddedResource Include="**\*.svg" />
            <EmbeddedResource Remove="bin\**" />
        </ItemGroup>
        <ItemGroup>
            <ProjectReference Include="..\MySolution.Module.Win\MySolution.Module.Win.csproj" />
            <ProjectReference Include="..\MySolution.Module\MySolution.Module.csproj" />
        </ItemGroup>
    </Project>
    
  3. In the new code, replace the “MySolution” placeholder with your project’s root namespace in the <RootNamespace> element and with the project’s name in the <ProjectReference> element.

  4. If you reference other projects or NuGet packages, copy corresponding <ProjectReference> elements from the old version of the csproj files and paste them into the new version.

  5. If your projects require other resources (for example, PNG images), include them in <EmbeddedResource> elements.

  6. Reload all projects.

  7. In the Program.cs (Program.vb) file, comment the following line:

    static class Program {
        // ...
        static void Main() {
            // ...
            EditModelPermission.AlwaysGranted = System.Diagnostics.Debugger.IsAttached;
        }
    }
    
  8. In the App.config file, remove the <system.diagnostics> element and add the code below to <appSettings>:

    <?xml version="1.0"?>
    <configuration>
    <!-- ... -->
        <appSettings>
        <!-- ... -->
            <add key="eXpressAppFrameworkTraceLevel" value="3"/>
        </appSettings>
    </configuration>
    

    .NET 6+ applications use this key instead of switches in the <system.diagnostics> element.

    If you use EasyTest in your application, add the following keys:

    <?xml version="1.0"?>
    <configuration>
    <!-- ... -->
        <appSettings>
        <!-- ... -->
            <add key="EasyTestTraceLevel" value="4"/> 
            <add key="EasyTestLogFileName" value="TestExecutor.log" />
        </appSettings>
    </configuration>
    
  9. Optional. Enable the latest framework settings at the top of the Main method:

    namespace MySolution.Win {
        static void Main() {
            DevExpress.ExpressApp.FrameworkSettings.DefaultSettingsCompatibilityMode = DevExpress.ExpressApp.FrameworkSettingsCompatibilityMode.Latest;
            // ...
        }
    }
    
  10. Rebuild the solution.

  11. If you port an EF 6-based application, you also need to move to EF Core because .NET 6+ applications do not support EF 6. This move may require additional changes to your application. For more information, refer to the following article: Port from EF6 to EF Core.

Note

Refer to the following topic for information on how to deploy the ported application: Deploy .NET Applications.

Port an XAF App from .NET Core 3 to .NET 6

To simplify the migration process, the DevExpress Project Converter attempts to retarget your XAF projects to .NET 6+ automatically. Our Project Converter does not update your non-XAF projects, custom dependencies, or code. In this case, you need to complete .NET 6+ migration manually.

Follow the steps below only if you need to update your application manually. See the following topic for more information: Core - XAF’s Blazor and WinForms (.NET Core) assemblies target .NET 5.

WinForms

In the SolutionName.Module.Win and SolutionName.Win project files (and related WinForms .NET 6+ modules), set the TargetFramework option to net6.0-windows:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0-windows</TargetFramework> 

ASP.NET Core Blazor

In the SolutionName.Module.Blazor project file, set the TargetFramework option to net6.0 and set the Sdk option to Microsoft.NET.Sdk.Razor:

<Project Sdk="Microsoft.NET.Sdk.Razor">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>

In the SolutionName.Blazor.Server project file (and related ASP.NET Core Blazor .NET 6+ modules), set the TargetFramework option to net5.0 and set the Sdk option to Microsoft.NET.Sdk.Web:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
See Also