简体   繁体   English

构建时 Visual Studio 中出现奇怪的功能区错误

[英]Strange Ribbon error in Visual Studio when building

I'm receiving a strange error in Visual Studio when building my WPF application with .NET 4.5 in Visual Studio 11.在 Visual Studio 11 中使用 .NET 4.5 构建 WPF 应用程序时,我在 Visual Studio 中收到一个奇怪的错误。

My WPF XAML markup is as follows:我的 WPF XAML 标记如下:

<RibbonWindow x:Class="Fablelane.DesktopApplication.CreateStory"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Create new story" Height="468" Width="526">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Ribbon>
            <Ribbon.ApplicationMenu>
                <RibbonApplicationMenu>
                </RibbonApplicationMenu>
            </Ribbon.ApplicationMenu>
            <RibbonTab Margin="0" Header="Format">
                <RibbonGroup Header="Font">
                    <StackPanel Orientation="Horizontal">
                        <RibbonComboBox>
                            <RibbonGallery SelectedValue="Heading 1"
                          SelectedValuePath="Content"
                          MaxColumnCount="1">
                                <RibbonGalleryCategory>
                                    <RibbonGalleryItem Content="Heading 1" Foreground="#16ea00" FontSize="20" />
                                    <RibbonGalleryItem Content="Heading 2" Foreground="#00c6ff" FontSize="18" />
                                    <RibbonGalleryItem Content="Heading 3" Foreground="#999999" FontSize="16" />
                                    <RibbonGalleryItem Content="Heading 3" Foreground="#707070" FontSize="14" />
                                    <RibbonGalleryItem Content="Content" Foreground="#FF606060" />
                                </RibbonGalleryCategory>
                            </RibbonGallery>
                        </RibbonComboBox>
                    </StackPanel>
                    <RibbonControlGroup Margin="2">
                        <RibbonToggleButton Label="B"
    FontWeight="Bold" FontFamily="Times New Roman" Padding="2" />
                        <RibbonToggleButton Label="I"
    FontStyle="Italic" FontFamily="Times New Roman" Padding="2" />
                        <RibbonToggleButton Label="U" FontFamily="Times New Roman" Padding="2,2,2,0" />
                    </RibbonControlGroup>
                </RibbonGroup>
            </RibbonTab>
            <RibbonTab Margin="0" Header="Options">
            </RibbonTab>
        </Ribbon>
        <RichTextBox Grid.Row="1">

        </RichTextBox>
    </Grid>
</RibbonWindow>

Now, when I build, I receive the error:现在,当我构建时,我收到错误:

Unknown build error, 'Method 'get_Command' in type 'System.Windows.Controls.Ribbon.RibbonGallery' from assembly 'System.Windows.Controls.Ribbon, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' does not have an implementation.未知的构建错误,来自程序集“System.Windows.Controls.Ribbon, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的“System.Windows.Controls.Ribbon.RibbonGallery”类型中的“Method 'get_Command'没有一个实现。

When I remove the RibbonGallery element from the code, it compiles and runs just fine.当我从代码中删除 RibbonGallery 元素时,它编译并运行得很好。

It should probably be noted that I can easily see the designer view rendering just fine in Visual Studio with the RibbonGallery element inside of it.应该注意的是,我可以很容易地看到设计器视图在 Visual Studio 中呈现得很好,其中包含 RibbonGallery 元素。 It just fails during build.它只是在构建过程中失败。

对我来说它看起来像一个错误,为什么不使用反射器并检查 ICommand 的 getter 是否正确暴露?

I can't see a problem.我看不出有什么问题。

If I look at the Ribbon assembly using DotPeek, then I can see the Command property如果我使用 DotPeek 查看 Ribbon 程序集,那么我可以看到 Command 属性

public ICommand Command
{
  get
  {
    return (ICommand) this.GetValue(RibbonGallery.CommandProperty);
  }
  set
  {
    this.SetValue(RibbonGallery.CommandProperty, (object) value);
  }
}

but then you don't seem to be using it.但是你似乎没有使用它。

Is it worth creating a new test app from scratch?从头开始创建一个新的测试应用程序值得吗?

从 4.0 到 4.8,我们遇到了同样的问题,但我们必须删除正确的 system.dll 并将其重新添加到引用中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM