2012-02-27 88 views
0

我已經搜索論壇,但是我沒有找到任何讓我非常滿意的東西。WPF用戶控制錯誤

在Microsoft Visual Studio 2010中,當我嘗試添加一個WPF用戶控件我得到這個錯誤:

"Value cannot be null. Parameter name: objectType" 

然後,當我想選擇託管內容,我得到這個錯誤:

"An error occured trying to add references for type 'PolyPuttZe.GameCanvas', or finding the type. Make sure the project references are correct." 

我跟着本教程:http://www.switchonthecode.com/tutorials/wpf-tutorial-using-wpf-in-winforms

謝謝!

編輯:

這是我寫的代碼:

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 
using System.Windows.Forms.Integration; 

namespace PolyPuttZe 
{ 
    public partial class Game : Form 
    { 
     public Game() 
     { 
      InitializeComponent(); 
     } 
    } 
} 
+0

因此,顯示一些細節。這是在一個ElementHost裏面嗎?你寫了一個objectType參數的方法嗎? – 2012-02-27 20:57:52

+0

我遵循了這些步驟,並能看到winforms中的下拉列表。你在做完教程後是否修改了代碼?請顯示你的代碼。 – 2012-02-27 21:03:40

+0

我沒有寫任何代碼......只有Visual Studio自動生成的代碼。 Visual Studio在工具箱中知道我的WPF用戶控件,但是當我嘗試將其放入我的設計器時,我遇到了錯誤。 – LolCat 2012-02-27 21:16:49

回答

0

我得到它的工作!我所做的只是從頭開始。我刪除了這個項目並在另一臺計算機上創建了一個新項目。然後錯誤消失了,它正在工作。感謝所有幫助過我的人!