2009-04-24 4 views
0

実行時にxamlファイルをロードしようとしています。私のコードは次のようになります。XamlReader.Load(XmlReader) "Stack Empty" XamlParseException

StringReader stringReader = new StringReader(xamlString);   
      XmlReader xmlReader = XmlReader.Create(stringReader); 
      content = XamlReader.Load(xmlReader); 

それは基本的には、MSDNのペーストをコピーします。 XamlReader.Load行はXamlParseExceptionをスローし、 "Stack Empty at Line ...."という内部例外が発生します。
それが指している行は、文字列の最後の行であるxaml文字列にあるユーザーコントロールの終了タグです。グーグルは何を上げていなかった

<UserControl> 
    <UserControl.Resources> 
    </UserControl.Resources> 
    <Grid> 
    </Grid> 
</UserControl> 

次のように

基本的なXAML構造です。解決策を見つける上で助けがあれば幸いです。

+0

で犯人と全体のヘッダであるあなたは、WPFを使用していますか? – TStamper

+0

はい、私はwpfとxamlを使用しています。 – JRobbers

答えて

0

エラーがなくなるまで、xamlからブロックを削除し始めました。私は私のユーザーコントロールの宣言

<UserControl 
... 
WPFManagement:ObjectReference.Declaration="{WPFManagement:ObjectReference thisPointer}" 
...> 

それはスタック空の例外をスローする理由は正確にわからないで見つかったこのラインにそれを絞り込むことができたが、それはありません。ここで

は大胆

<UserControl 
     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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:WPFManagement="clr-namespace:A;assembly=A" 
     xmlns:WPFControls="clr-namespace:B;assembly=B" 
     xmlns:ModuleUI="clr-namespace:C;assembly=C" 
     xmlns:GeneralUI="clr-namespace:D;assembly=D" 
     **WPFManagement:ObjectReference.Declaration="{WPFManagement:ObjectReference thisPointer}"** 
     mc:Ignorable="d" 
     WPFControls:UIExtension.Caption="Filler" 
     WPFControls:UIExtension.Icon="Icon" 
     d:DesignWidth="910" 
     d:DesignHeight="730">