.net 框架到 .net 5 迁移构建但不启动
.net framework to .net 5 migration build but does not launch
我刚刚将我的 .net Framework 4.8 项目迁移到 .net 5 中。
首先,我将旧的csproj 项目配置文件更改为新的。然后删除多余的程序集,最后删除或更新所有包。之后我启动了项目兼容性测试以查看我的所有项目是否与.net 5 兼容并启动项目。
奇怪的是,项目构建(我有一个 .exe)没有更多细节,启动并立即关闭,我唯一的线索是这条消息:
The target process terminated without raising a CoreCLR start event. Make sure the target process is
configured to use .NET Core. This can be expected behavior if the target process did not run on .NET Core.
Program 'test.exe' terminated with code -2147450740 (0x8000808c).
The program 'test.exe: Program trace' has stopped with code 0 (0x0).
我的 csproj 文件的一部分
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
有人知道哪里出了问题吗?
我通过以下步骤将目标为framework4.7的名为FrameworkToNet5的演示项目转换为.Net 5,并且成功,希望对您有所帮助参考至:
第一步:在Visual studio16.8.1中创建一个名为FrameworkToNet5的框架WPF项目,并安装Microsoft.Xaml.Behaviors.Wpf
在 Nuget 包中。
第 2 步:要启用设计器,请转至工具 > 选项 > 环境 > 预览功能和 select 使用预览 Windows 表单设计器.NET Core 应用选项。
第三步:右击FrameworkToNet5,进入Analyze and Code Cleanup
,点击Run Code Analysis
检查.Net 5.
第 4 步: 右键单击 packages.config
> Migrate packages.config to PackageReference
,然后 Select 所有 top-level
包。
第 5 步: 使用下面的代码替换 .csproj
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" />
</ItemGroup>
第 6 步: 使用下面的代码替换 AssemblyInfo.cs
的内容
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly )]
步骤 7:清理并重建项目。
我刚刚将我的 .net Framework 4.8 项目迁移到 .net 5 中。
首先,我将旧的csproj 项目配置文件更改为新的。然后删除多余的程序集,最后删除或更新所有包。之后我启动了项目兼容性测试以查看我的所有项目是否与.net 5 兼容并启动项目。
奇怪的是,项目构建(我有一个 .exe)没有更多细节,启动并立即关闭,我唯一的线索是这条消息:
The target process terminated without raising a CoreCLR start event. Make sure the target process is
configured to use .NET Core. This can be expected behavior if the target process did not run on .NET Core.
Program 'test.exe' terminated with code -2147450740 (0x8000808c).
The program 'test.exe: Program trace' has stopped with code 0 (0x0).
我的 csproj 文件的一部分
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
有人知道哪里出了问题吗?
我通过以下步骤将目标为framework4.7的名为FrameworkToNet5的演示项目转换为.Net 5,并且成功,希望对您有所帮助参考至:
第一步:在Visual studio16.8.1中创建一个名为FrameworkToNet5的框架WPF项目,并安装Microsoft.Xaml.Behaviors.Wpf
在 Nuget 包中。
第 2 步:要启用设计器,请转至工具 > 选项 > 环境 > 预览功能和 select 使用预览 Windows 表单设计器.NET Core 应用选项。
第三步:右击FrameworkToNet5,进入Analyze and Code Cleanup
,点击Run Code Analysis
检查.Net 5.
第 4 步: 右键单击 packages.config
> Migrate packages.config to PackageReference
,然后 Select 所有 top-level
包。
第 5 步: 使用下面的代码替换 .csproj
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" />
</ItemGroup>
第 6 步: 使用下面的代码替换 AssemblyInfo.cs
的内容using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly )]
步骤 7:清理并重建项目。