[英]The name 'InitializeComponent' does not exist in the current context(c#,xamarin)
[英]c# does not contain a definition for "InitializeComponent" and name "controlName" does not exist in current context
自 6 月以來,我一直在團隊中開發 windows 電話應用程序。 直到今天,所有同步都運行良好。 我同步了項目,vs 開始給我錯誤
我沒有改變任何東西,昨天它運行良好。 XAML 上的類名稱與代碼隱藏中的名稱匹配。
我已經嘗試退出所有 vs 實例,但問題仍然存在。
對我來說,問題在於:
項目結構
Project\Views\Page1.xaml
Project\Views\Page1.xaml.cs
上述頁面構造函數中的Page1.xaml.cs
的錯誤:
public sealed partial class Page1 : Page
{
public Page1()
{
this.InitializeComponent();
}
}
XAML文件
<Page
x:Class="App1.Page1"
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"
mc:Ignorable="d">
應該是x:Class="App1.Views.Page1"
因此,只需在班級名稱中輸入錯字即可。
關閉解決方案,刪除與解決方案關聯的.suo文件,刪除所有項目中的“bin”和“obj”文件夾。 然后在VS中重新打開解決方案,重建解決方案。
“suo”文件是一個隱藏文件,因此您可能需要在資源管理器中按 go 到菜單/查看,然后勾選“隱藏項目”選項。 在 VS2013 中,它與 .sln 文件位於同一文件夾中,在較新的版本中,它位於(隱藏).vs 文件夾中。
對我來說,問題是應用程序在后台運行。
任務欄中沒有應用程序 window 或圖標。 即使 Visual Studio 關閉,應用程序實例仍然存在,阻止我手動清除 Solution 中的/bin
和/obj
,因為 Windows 拋出了“當前正在使用的文件”異常。
解決辦法是
CTRL
+ SHIFT
+ ESC
) 終止應用程序重新啟動系統也將起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.