C# 生成时Visual Studio中出现奇怪的功能区错误
在VisualStudio11中使用.NET4.5构建WPF应用程序时,我在VisualStudio中收到一个奇怪的错误 我的WPF XAML标记如下所示:C# 生成时Visual Studio中出现奇怪的功能区错误,c#,wpf,ribbon,C#,Wpf,Ribbon,在VisualStudio11中使用.NET4.5构建WPF应用程序时,我在VisualStudio中收到一个奇怪的错误 我的WPF XAML标记如下所示: <RibbonWindow x:Class="Fablelane.DesktopApplication.CreateStory" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schem
<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.Ribbon Allery”中的“System.Windows.Controls.Ribbon Allery”类型中的“Method”get_Command“未实现,版本=4.0.0.0,区域性=中性,PublicKeyToken=b77a5c561934e089”
当我从代码中删除RibbonGallery元素时,它编译并运行得很好
可能需要注意的是,我可以很容易地在VisualStudio中看到designer视图渲染,其中包含RibbonGallery元素。它只是在构建过程中失败。对我来说,它看起来像一个bug,为什么不使用reflector并检查ICommand的getter是否正确暴露?我看不出有问题
- 我有VS11测试版和最新更新
- 下载Ribbon(2010年10月)自
- 创建新的WPF.NET4.5应用程序
- 添加对System.Windows.Controls.Ribbon的引用
- 将问题代码粘贴到应用程序中
- 设计,建造,运行,没问题
public ICommand Command
{
get
{
return (ICommand) this.GetValue(RibbonGallery.CommandProperty);
}
set
{
this.SetValue(RibbonGallery.CommandProperty, (object) value);
}
}
但是你似乎没有用它
从头开始创建一个新的测试应用程序是否值得?我们在4.0到4.8版本中遇到了同样的问题,但我们必须删除并重新将正确的system.dll添加到引用中。从错误中可以看出,接口似乎没有实现,最简单的方法是在Visual Studio中下载pdb,设置符号路径(禁用调试下的“仅调试我的代码”),然后使用resharper 5/6查找实现。如果找不到,请报告错误。对于解决方法,请自行实现接口并向库注册(但不确定功能区库是否允许您这样做)我有此错误。如果我从xaml中删除了库并在代码中创建了一个库,我会收到以下警告:对类型“System.Windows.Input.ICommand”的引用声明它是在“c:\Program Files(x86)\Reference Assembly\Microsoft\Framework\.NETFramework\v4.0\System.dll”中定义的,但找不到它。这可能是修复方法: