c# - 在发布后的代码中找不到 XAML 元素名称

标签 c# wpf xaml visual-studio-2013

my previous question 中所述我的问题始于 CefSharp 想要明确选择平台 x86x64。这导致了多个错误,其中在代码后面找不到任何 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.xamlMainWindow.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/

相关文章:

WPF 模板错误 - "Provide value on ' System.Windows.Baml2006.TypeConverterMarkupExtension' 引发了异常。”

wpf - (WPF MVVM)如何将用户控件从 ViewModel 中的集合添加到 View

c# - 从 list<string> 到 Checkbox.content 的字符串 - WPF/C#

c# - A-star (A*) 的曼哈顿启发式函数

c# - 线程类 'Splash-Type' 屏幕的 TPL 等效项

c# - ScrollViewer 控件模板中断文本框

c# - 来自 json 的 XAML GridView 设计时数据

c# - 用Deflate算法解压Span<byte>中的数据

c# - 如何从 Windows Phone 8.1 发现蓝牙低功耗设备 (BLE)

c# - 完全关闭辅助窗口