![](/img/trans.png)
[英]New .Net MAUI App project throws 'The name 'InitializeComponent' does not exist in the current context' build errors
[英].NET Maui The name 'InitializeComponent' does not exist in the current context
當我執行Project / rt-click / Add / NewItem /.Net Maui ResourceDictionary (XAML)
時,這是添加到.csproj 的內容:
<MauiXaml Update="Dictionary1.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
請注意, Compile
嵌套在MauiXaml
元素中; 它不是一個單獨的項目。
查看 your.csproj 是否有兩個單獨的項目,一個用於Dictionary1.xaml
,另一個用於Dictionary1.xaml.cs
。
如果是這樣,請將這兩項替換為如上所示的組合項。
(對我來說,這沒有問題。)
在您的情況下,the.csproj 不顯示MauiXaml
BuildAction?
代替:
<ItemGroup>
<None Include="Themes\Light.xaml" />
</ItemGroup>
和:
<ItemGroup>
<MauiXaml Update="Themes\Light.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
我不知道這是應該保留還是刪除:
<ItemGroup>
<Folder Include="Themes\" />
</ItemGroup>
暫時保留它。
這聽起來像是一個經常困擾 Xamarin 解決方案的類似問題。 我認為存在一個潛在的錯誤,或者在 Visual Studio 中顯示時解釋文件的延遲。
幾個選項:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.