2010-09-21 28 views
1

在此代碼的執行過程中出現錯誤 無法序列化嵌套的公共類型「System.Windows.Forms.AxHost + State」。錯誤無法序列化嵌套的公共類型。爲什麼?

FlashControl我的用戶

<UserControl x:Class="Adminka.UserControls.FlashControl" 
      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" 
      xmlns:controls="clr-namespace:MyBlogUserControls;assembly=MyBlogUserControls"> 
    <Grid> 
     <controls:FlashPlayer/> 
    </Grid> 
</UserControl> 

flash播放器 - 用戶控件的顯示快閃

fd被一個RichTextBox,我需要更換FlashControl的文本框,但出現錯誤

error - Cannot serialize a nested public type 'System.Windows.Forms.AxHost+State'. 


    for (int i = 0; i < fd.Blocks.Count; i++) 
    { 
     var block = (fd.Blocks as BlockCollection).ElementAt(i); 
     if (block is Paragraph) 
     { 
      var p = new Paragraph(); 
      for (int y = 0; y < ((Paragraph)block).Inlines.Count; y++) 
      { 
       var inline = ((Paragraph)block).Inlines.ElementAt(y); 
       if (inline is InlineUIContainer) 
       { 
        var elem = ((InlineUIContainer)inline).Child; 
        if (elem is FlashControl) 
        { 
         elem = new TextBox() { Text = string.Format(format, "FlashControl", (elem as FlashControl).FlashPlayer.Source) }; 
        } 
        ((InlineUIContainer)inline).Child = null; \\error occurs here 
       } 
      } 
      block = p; 
     } 
    } 

如何替換TextBox上的FlashControl?

回答

0

爲了解決這個問題,我最終將我的類型聲明移到了我的類之外(因此它不再是'嵌套')。