2011-12-16 119 views
0

我正在一個WPF項目中遇到一個惡性循環。起初,我得到」clr-namespace'{0}'not found「和」InitializeComponent does not exist「雙重問題

The 'clr-namespace' URI refers to a namespace '{0}' that is not included in the assembly 

我已經能夠解決這個問題(首先),但它引入了另一個錯誤:

The name 'InitializeComponent' does not exist in the current context 

然而,解決這一問題再次引起了第一個。相關XAML代碼如下所示(簡化):

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:local="clr-namespace:Main_Namespace" 
     Title="Client" WindowState="Maximized" MinWidth="800" MinHeight="600"> 

</Window> 

請注意,我的主命名空間實際上它有一個空間....也許這就是造成錯誤?我知道Visual Studio(以及其他任何代碼編輯器)對於如何命名文件是相當挑剔的...

回答

2

您的文件不再與您的代碼鏈接(因此沒有InitializeComponent),您以某種方式管理殺死x:Class directive。不知道該怎麼做空間雖然...

+0

這似乎工作。它編譯得很好......我現在在使用默認構造函數的類的構造函數上得到一個System.NotImplementedException ...>。> – ThaMe90 2011-12-16 08:38:31

0

在我的情況下,我從一個項目複製XAML文件到另一個。您需要將這些xaml文件設置爲文件屬性中的「頁面」。如果xaml編譯器運行,則會在Window.xaml.g.cs中生成IntializeCompounent。

相關問題