外部程序集在设计时不工作
External assemblies not working at design time
我遇到了一个问题,我找不到解决方案(到目前为止我发现的一切都与我的问题无关)。出于某种原因,每当我尝试使用来自外部程序集的任何内容时,我的 Visual Studio(我将 2015 Community Edition 与 Resharper Ultimate 2015.1.3 一起使用)在设计时向我显示错误和警告,这使我无法看到window。这包括样式和 类(例如 MahApps 的 MetroWindow)。当我编译并 运行 时一切正常。
我可以提供的一个示例是 http://www.codeproject.com/Articles/442856/Visual-Studio-Metro-Styles-for-WPF 中公开可用的演示代码,但实际上,任何使用外部 类 的代码都可以。
我收到的警告是:"Assembly 'MahApps.Metro' is not referenced by this project" - 显然已被引用。
错误:"The name "MetroWindow“在命名空间 "clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" 中不存在。”
"faulty" 代码的示例是 window 定义本身,直接取自示例。
<Controls:MetroWindow x:Class="Selen.Wpf.DemoApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:System="clr-namespace:System;assembly=mscorlib" Title="Enterprise Commander"
Height="800" Width="1000" WindowStartupLocation="CenterScreen" TitleForeground="#999988"
ShowMaxRestoreButton="False">
...
</Controls:MetroWindow>
编辑:我找到了一个解决方法——删除 MahApps 并使用 NuGet 读取它有帮助。虽然不得不这样做感觉不对。
至少对于 MahApps 你应该试试
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
而不是
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
答案是删除 MahApps 并使用 NuGet 再次添加它 - 我想这就是我将来应该添加外部内容的方式。
我遇到了一个问题,我找不到解决方案(到目前为止我发现的一切都与我的问题无关)。出于某种原因,每当我尝试使用来自外部程序集的任何内容时,我的 Visual Studio(我将 2015 Community Edition 与 Resharper Ultimate 2015.1.3 一起使用)在设计时向我显示错误和警告,这使我无法看到window。这包括样式和 类(例如 MahApps 的 MetroWindow)。当我编译并 运行 时一切正常。 我可以提供的一个示例是 http://www.codeproject.com/Articles/442856/Visual-Studio-Metro-Styles-for-WPF 中公开可用的演示代码,但实际上,任何使用外部 类 的代码都可以。
我收到的警告是:"Assembly 'MahApps.Metro' is not referenced by this project" - 显然已被引用。
错误:"The name "MetroWindow“在命名空间 "clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" 中不存在。”
"faulty" 代码的示例是 window 定义本身,直接取自示例。
<Controls:MetroWindow x:Class="Selen.Wpf.DemoApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:System="clr-namespace:System;assembly=mscorlib" Title="Enterprise Commander"
Height="800" Width="1000" WindowStartupLocation="CenterScreen" TitleForeground="#999988"
ShowMaxRestoreButton="False">
...
</Controls:MetroWindow>
编辑:我找到了一个解决方法——删除 MahApps 并使用 NuGet 读取它有帮助。虽然不得不这样做感觉不对。
至少对于 MahApps 你应该试试
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
而不是
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
答案是删除 MahApps 并使用 NuGet 再次添加它 - 我想这就是我将来应该添加外部内容的方式。