HtmlFormatProvider in console application

2 posts, 0 answers
  1. Gerrit Fölster
    Gerrit Fölster avatar
    6 posts
    Member since:
    Sep 2009

    Posted 21 Jan 2013 Link to this post

    Hi Telerik Team,

    I'm trying to use the Wpf HtmlFormatProvider (Version 3/12) in a console application. 

    [STAThread]
    static void Main(string[] args)
    {
        HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
        try
        {
             RadDocument doc = htmlProvider.Import(htmlString);
        }
        catch (Exception ex)
        {
     
        }
    }


    When the input html is malformed the FormatProvider throws an exception on a different thread
    which is crashing the application. 

    Is there any workaround for this?
  2. Mihail
    Admin
    Mihail avatar
    196 posts

    Posted 24 Jan 2013 Link to this post

    Hello Gerrit ,

    The problem is the there is no instance of Application and the resources of Telerik.Windows.Documents are not accessible. Creating a new instance will fix the problem.

    [STAThread]
    static void Main(string[] args)
    {
        if (Application.Current == null)
        {
            new Application();
        }
     
        HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
        RadDocument doc = null;
        try
        {
            string a = "<img src=\"text:text:text.,text;; text text\" />";
            doc = htmlProvider.Import(a);
        }
        catch (Exception ex)
        {
        }
     
    }

    If you have further questions feel free to contact us again.

    Regards,
    Mihail
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top