This is a migrated thread and some comments may be shown as answers.

HtmlFormatProvider in console application

1 Answer 61 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Gerrit Fölster
Top achievements
Rank 1
Gerrit Fölster asked on 21 Jan 2013, 03:25 PM
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?

1 Answer, 1 is accepted

Sort by
0
Mihail
Telerik team
answered on 24 Jan 2013, 03:07 PM
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.

Tags
RichTextBox
Asked by
Gerrit Fölster
Top achievements
Rank 1
Answers by
Mihail
Telerik team
Share this question
or