wpf - 2wpf .net5 错误当前上下文中不存在名称“InitializeComponent”
问题描述
我在 Visual Studio 2019 中创建了一个新项目并选择“WPF 应用程序”.net5 并尝试构建生成的应用程序,但出现了两个错误
当前上下文中不存在名称“InitializeComponent”。
程序不包含适用于入口点的静态“Main”方法。
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace WpfApp1
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
<Application x:Class="WpfApp1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApp1"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
解决方案
我创建了一个空解决方案并将其存档在 Google Disk Empty Application
上
下载并尝试在 Visual Studio 中打开它。
如果它打开,则意味着您的项目类型错误,或者用于创建解决方案的模板中存在错误。
如果它没有打开,那么 Studio 本身就有问题。
报告结果以了解在哪个方向寻找问题的解决方案。
推荐阅读
- php - 如何在 PHP CRUL 中接收来自 API 的响应并将其初始化为变量?
- ansible - AWX - 如何/在何处修改全局作业设置
- python - 使用python从plesk(GODADDY)连接mysql时出错
- r - 来自核酸词的系统发育树
- javascript - 如何将 p 标签中的文本回调到输入文本字段?
- ruby-on-rails - 如何在助手中嵌套 Rails 标签?
- java - 在页面中打印 for 循环时遇到问题
- javascript - 在我的程序 Javascript 中导入 csv 文件
- arrays - 在 C 中对 const char* 字符串数组进行排序 - 练习
- java - 如何检查带小数的字符串数字是双精度还是整数?