开发者

Error Cannot serialize a nested public type. Why?

In the performance of this code is an error:

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

FlashControl my usercontrol:

<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>

FlashPlayer - usercontrol for view flash. 'fd' is a RichTextbox. I need to replace the FlashControl on the TextBox, but an error occurs:

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 occu开发者_如何学编程rs here
                }
            }
            block = p;
        }
    }

How to replace the FlashControl on the TextBox?


In order to get around this, I ended up moving my type declaration outside of my class (thus it was no longer 'nested').

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜