如 my previous question 中所述我的问题始于 CefSharp
想要明确选择平台 x86
或 x64
。这导致了多个错误,其中在代码后面找不到任何 XAML
元素,包括 InitializeComponent();
。我删除了 CefSharp
并再次设置为 AnyCPU
。现在 Debug
模式运行良好,但是当我再次切换到 Release
时,同样的错误发生了。
这两种模式有什么不同?我在哪里可以修复这些错误?
Error The name 'InitializeComponent' does not exist in the current context d:\visual studio\projects 2013\solutionname\projectname\ui\mainwindow.xaml.cs
Error The name 'MenuItemAutoLogin' does not exist in the current context d:\visual studio\projects 2013\solutionname\projectname\ui\mainwindow.xaml.cs
Error The name 'MenuItemAutoLogin' does not exist in the current context d:\visual studio\projects 2013\solutionname\projectname\ui\mainwindow.xaml.cs
Error The name 'treeViewNotes' does not exist in the current context d:\visual studio\projects 2013\solutionname\projectname\ui\mainwindow.xaml.cs
Error The name 'treeViewNotes' does not exist in the current context d:\visual studio\projects 2013\solutionname\projectname\ui\mainwindow.xaml.cs
*如果重要的话,MainWindow.xaml
和 MainWindow.xaml.cs
都在 Project_Namescape.UI
子命名空间中
编辑:删除 Obj
文件夹 + Clean
+ Rebuild
不会修复错误。
最佳答案
毕竟错误是我自己的。我在解决方案中有一个直接从 Debug
文件夹引用的第三方 dll。即使 CopyLocal
设置为 True
,dll 也不会自动复制到 Release
文件夹中。
现在我已经移动了 Resources
文件夹中的 dll 并重新引用了它。一切都很完美。
关于c# - 在发布后的代码中找不到 XAML 元素名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30800456/