Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# .net framework到.net 5的迁移生成,但未启动_C#_.net_Wpf_Visual Studio_.net 5 - Fatal编程技术网

C# .net framework到.net 5的迁移生成,但未启动

C# .net framework到.net 5的迁移生成,但未启动,c#,.net,wpf,visual-studio,.net-5,C#,.net,Wpf,Visual Studio,.net 5,我刚刚将.NETFramework4.8项目迁移到.NET5项目中 首先,我将旧的csproj项目配置文件更改为新的。然后删除冗余部件,最后删除或更新所有包。之后,我启动了项目兼容性测试,以查看我的所有项目是否与.NET5兼容,然后启动该项目 奇怪的是,在没有更多详细信息的情况下,项目构建(我有一个.exe)立即启动并关闭,我唯一的线索是以下消息: The target process terminated without raising a CoreCLR start event. Make

我刚刚将.NETFramework4.8项目迁移到.NET5项目中

首先,我将旧的csproj项目配置文件更改为新的。然后删除冗余部件,最后删除或更新所有包。之后,我启动了项目兼容性测试,以查看我的所有项目是否与.NET5兼容,然后启动该项目

奇怪的是,在没有更多详细信息的情况下,项目构建(我有一个.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>

net5.0-windows
真的
真的

有人知道出了什么问题吗?

我通过以下步骤将名为Framework的演示项目转换为ET5,目标是framework4.7到.Net 5,并且成功了,希望能对您有所帮助:

步骤1:在Visual studio 16.8.1中创建名为FrameworkToNet5的框架WPF项目,并在Nuget包中安装
Microsoft.Xaml.Behaviors.WPF

步骤2:要启用设计器,请转到工具>选项>环境>预览功能,然后选择使用.NET核心应用程序的预览Windows窗体设计器选项

步骤3:右键单击FrameworkToNet5,转到
分析和代码清理
,单击
运行代码分析
检查.Net 5

步骤4:右键单击
packages.config
将packages.config迁移到PackageReference
,然后选择所有顶级的

步骤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>

步骤7:清理并重建项目。

如何运行test.exe?您只是直接启动test.exe吗?请检查已安装的net 5 sdk和运行时。我使用visual studio启动了test.exe,并尝试直接启动它,但没有发生任何情况,窗口不显示。我安装了最新版本的.net 5 SDK。是否尝试创建新的.net 5项目并将旧项目中的现有项添加到该项目中?
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, 
ResourceDictionaryLocation.SourceAssembly )]