首页 > 解决方案 > 在调试和构建 WPF 应用程序时遇到问题

问题描述

我一直在对我们几年前使用 ModernUI 框架编写的 WPF 应用程序进行修改,添加一个共享项目,进行必要的更改。但是,我发现我既不能调试应用程序,也不能构建它。当我尝试调试应用程序时,我收到此错误:

System.Windows.Markup.XamlParseException
  HResult=0x80131501
  Message='Provide value    on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '7' and line position '19'.
  Source=PresentationFramework
  StackTrace:
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
   at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   at LRAT.MainWindow.InitializeComponent() in D:\Src\LRAT\Labor Relations Action Tracker (LRAT)\LRAT\LRAT\MainWindow.xaml:line 1

Inner Exception 1:
IOException: Cannot locate resource 'assets/14546169_s-01.ico'.

我在整个项目中搜索。在几个 ModernWindow 中有两个地方有那个 .ico 文件的 Icon 属性的值。但是,我将其更改为:

<mui:ModernWindow x:Class="LRAT.MainWindow"                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mui="http://firstfloorsoftware.com/ModernUI"
              xmlns:view="clr-namespace:LRAT.View"
              xmlns:uc="clr-namespace:LRAT.UserControls"
              Style="{StaticResource BlankWindow}"    
              Closing="ModernWindow_Closing"
              Icon="/Assets/14546169_S-01.ico" 
              Loaded="ModernWindow_Loaded" 
    >

所以,我不知道还能去哪里看,因为搜索整个解决方案并没有显示类似 assets/14546169_s-01.ico 的任何内容,而我已将 2 个 .xaml 文件更改为 /assets/14546169_s-01 .ico。

如果我尝试构建它,其余的就更奇怪了。它告诉我的只是

Unknown build error, 'An item with the same key has already been added.'

它唯一说的是问题出在 LRAT 项目中。没有提到文件。

我们从 VS 2017 开始这个项目。我在那里得到了错误。我也通过 VS 2019 获得它们。

标签: wpfvisual-studio-2017modern-uivisual-studio-2019

解决方案


推荐阅读