2011-03-07 81 views
0

這讓我很難過。我試圖用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。

關於如何使這項工作的任何建議?

回答

0

可以肯定的是,您的用戶控件託管在一個窗口或其他東西中?我很確定你不能單獨顯示一個usercontrol。你的包含窗口是什麼樣的?

+0

不,我沒有包含窗口,但我認爲這是用戶控制測試容器的全部重點。這是一個「WPF用戶控制庫」,而不是「WPF應用程序」,所以沒有「主要」功能,但是從我所瞭解的UCTC生成的窗口中,可以單獨測試UC組件,而無需啓動整個應用程序。我錯了嗎? – terrance 2011-03-08 14:00:56

+0

只注意到在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

0

UserControl Test Container僅適用於使用Windows控件庫項目模板構建的庫。即使那樣,它也是一個子集,因爲Visual C++控件無法使用它進行測試。