.NET Core 3.0+
.NET Framework 4.5.2+
The page you are viewing does not exist in the .NET Framework 4.5.2+ platform documentation. This link will take you to the parent topic of the current section.
.NET Standard 2.0+
The page you are viewing does not exist in the .NET Standard 2.0+ platform documentation. This link will take you to the parent topic of the current section.
.NET Core 3.0+

Port an Existing XAF Application to .NET Core 3.0+

  • 2 minutes to read

Follow the steps below to port your XAF WinForms application from .NET Framework to .NET Core. Refer to the .NET Core 3.0+ Support in XAF WinForms Applications topic to make sure that your application can be migrated and all required components are installed on your machine.

IMPORTANT

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

  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.WindowsDesktop">
        <PropertyGroup>
            <OutputType>Library</OutputType>
            <TargetFramework>netcoreapp3.1</TargetFramework>
            <UseWindowsForms>true</UseWindowsForms>
            <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
            <RootNamespace>MySolution.Module</RootNamespace>
            <Deterministic>False</Deterministic>
        </PropertyGroup>
        <ItemGroup>
            <EmbeddedResource Include="**\*.svg" />
            <EmbeddedResource Include="**\*.xafml" />
            <EmbeddedResource Remove="bin\**" />
        </ItemGroup>
        <ItemGroup>
            <PackageReference Include="DevExpress.WindowsDesktop.Core" Version="20.1.6" />
            <PackageReference Include="DevExpress.WindowsDesktop.Xaf" Version="20.1.6-ctp" />
        </ItemGroup>
    </Project>
    
    NOTE

    You can also add a list of specific XAF NuGet packages instead of DevExpress.WindowsDesktop.Xaf that contains all other XAF packages.

    MySolution.Module.Win

    <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
        <PropertyGroup>
            <OutputType>Library</OutputType>
            <TargetFramework>netcoreapp3.1</TargetFramework>
            <UseWindowsForms>true</UseWindowsForms>
            <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
            <RootNamespace>MySolution.Module.Win</RootNamespace>
            <Deterministic>False</Deterministic>
        </PropertyGroup>
        <ItemGroup>
            <EmbeddedResource Include="**\*.svg" />
            <EmbeddedResource Include="**\*.xafml" />
            <EmbeddedResource Remove="bin\**" />
        </ItemGroup>
        <ItemGroup>
            <ProjectReference Include="..\MySolution.Module\MySolution.Module.csproj" />
        </ItemGroup>
    </Project>
    

    MySolution.Win

    <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
        <PropertyGroup>
            <OutputType>WinExe</OutputType>
            <TargetFramework>netcoreapp3.1</TargetFramework>
            <UseWindowsForms>true</UseWindowsForms>
            <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
            <RootNamespace>MySolution.Win</RootNamespace>
            <Deterministic>False</Deterministic>
        </PropertyGroup>
        <ItemGroup>
            <EmbeddedResource Include="**\*.svg" />
            <EmbeddedResource Include="**\*.xafml" />
            <EmbeddedResource Remove="bin\**" />
        </ItemGroup>
        <ItemGroup>
            <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.2.1" />
            <PackageReference Include="System.Data.SqlClient" Version="4.7.0-preview.19073.11" />
            <PackageReference Include="System.Diagnostics.PerformanceCounter" Version="4.6.0-preview8.19405.3" />
        </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 one.

  5. If your projects require other resources (e.g., 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 Core 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. Rebuild the solution.

NOTE

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