簡體   English   中英

構建時 Visual Studio 中出現奇怪的功能區錯誤

[英]Strange Ribbon error in Visual Studio when building

在 Visual Studio 11 中使用 .NET 4.5 構建 WPF 應用程序時,我在 Visual Studio 中收到一個奇怪的錯誤。

我的 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>

現在,當我構建時,我收到錯誤:

未知的構建錯誤,來自程序集“System.Windows.Controls.Ribbon, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的“System.Windows.Controls.Ribbon.RibbonGallery”類型中的“Method 'get_Command'沒有一個實現。

當我從代碼中刪除 RibbonGallery 元素時,它編譯並運行得很好。

應該注意的是,我可以很容易地看到設計器視圖在 Visual Studio 中呈現得很好,其中包含 RibbonGallery 元素。 它只是在構建過程中失敗。

對我來說它看起來像一個錯誤,為什么不使用反射器並檢查 ICommand 的 getter 是否正確暴露?

我看不出有什么問題。

  • 我有最新更新的 VS 11 Beta。
  • http://www.microsoft.com/en-us/download/details.aspx?id=11877下載功能區(2010 年 10 月)
  • 創建新的 WPF .NET 4.5 應用程序
  • 添加對 System.Windows.Controls.Ribbon 的引用
  • 將問題中的代碼粘貼到應用程序中
  • 設計、構建、運行,沒問題

如果我使用 DotPeek 查看 Ribbon 程序集,那么我可以看到 Command 屬性

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

但是你似乎沒有使用它。

從頭開始創建一個新的測試應用程序值得嗎?

從 4.0 到 4.8,我們遇到了同樣的問題,但我們必須刪除正確的 system.dll 並將其重新添加到引用中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM