So I have been using the richtexteditor using Xaml. Recently I need to create a SSRS report (SQL Server reporting services) that display those data. I created an external library using the WPF version of the control in order to convert the data from Xaml format into plain text.
Except when I try to use this in SSRS I get this error:
The calling thread must be STA, because many UI components require this.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.Windows.Documents;
using Telerik.Windows.Documents.FormatProviders;
using Telerik.Windows.Documents.FormatProviders.Html;
using Telerik.Windows.Documents.FormatProviders.Xaml;
using Telerik.Windows.Documents.FormatProviders.Txt;
using System.Security;
using System.Threading;
[assembly: AllowPartiallyTrustedCallers]
namespace TelerikConvertor
{
public class TelerikConvertorClass
{
public string Xaml2Text(string XamlText)
{
try {
if (XamlText == null || !XamlText.StartsWith("<t:Ra"))
return XamlText;
XamlFormatProvider x = new XamlFormatProvider();
TxtFormatProvider t = new TxtFormatProvider();
return t.Export(x.Import(XamlText));
}
catch (Exception e)
{
return e.Message;
}
}
public string HelloWorld()
{
return "hello world";
}
}
}