这让我很难过。我试图用User Control Test Container.exe在Visual Studio 2010中测试/调试WPF UserControl库。我一直收到错误“Assembly [...]不包含任何UserControls。”这应该很简单,并且我看过的每个msdn文章和博客教程都表明它应该都可以完美并且神奇地工作。用户控制测试容器:程序集不包含任何用户控件
下面是一个非常简单的测试情况下,我不能让工作代码:
XAML:
<UserControl x:Class="UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Label Content="Hello!" Height="28" HorizontalAlignment="Left" Margin="86,106,0,0" Name="Label1" VerticalAlignment="Top" />
</Grid>
代码背后:
Public Class UserControl1
Inherits UserControl
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
End Class
项目文件调试选项设置以./MyTestLibrary.dll作为命令行参数打开UserControlTestContainer.exe。
关于如何使这项工作的任何建议?
不,我没有包含窗口,但我认为这是用户控制测试容器的全部重点。这是一个“WPF用户控制库”,而不是“WPF应用程序”,所以没有“主要”功能,但是从我所了解的UCTC生成的窗口中,可以单独测试UC组件,而无需启动整个应用程序。我错了吗? – terrance 2011-03-08 14:00:56
只注意到在exceptionSystem.ArgumentException:Assembly'./WpfControlLibrary_Tutorial1.dll'不包含任何UserControl类型。在Microsoft.VisualStudio.Tools.UserControlTestContainer.UserControlTestContainer_Load(Object sender,EventArgs e) at System.Windows.Forms.Form.OnLoad(EventArgs e) ...等等,UCTC只使用Forms命名空间而不是WPF命名空间。我将这意味着UCTC只能用于WinForms UserControls,而不是WPF UserControls。 Thx浪费了我三天的时间,微软。 – terrance 2011-03-09 19:39:01