姓名" X"命名空间中不存在" clr-namespace:Y; assembly = Z"

时间:2016-04-02 16:48:27

标签: c# .net wpf c#-4.0

我最近为WPF设计了一个自定义窗口。但是我遇到了TargetType和clr-namespace的问题。

代码是:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:sf="clr-namespace:Suite.Forms;assembly=bhsuite">
<Style TargetType="{x:Type Button}" x:Key="WButtonStyle">

</Style>
<Style TargetType="{x:Type Button}" x:Key="ButtonStyle">

</Style>
<Style TargetType="{x:Type sf:BHWindow}" x:Key="BHWindowStyle">

</Style>

问题显然在BHWindowStyle,我尝试使用sf:BHWindow

我试过了:

  • 添加;assembly=MyAssembly
  • 包含在项目参考中:
    • PresentationCore
    • PresentationFramework
    • WindowsBase
    • System.Xaml
  • 以管理员身份重新启动
  • 清洁和重建
  • 将构建平台从x86更改为x64以进行清理和重建。

1 个答案:

答案 0 :(得分:0)

通过删除xmlns:sf="clr-namespace:Suite.Forms;assembly=bhsuite",编译,重写然后重新编译项目来解决。