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

Silverlight Documents manipulated in non SL assemblies

5 Answers 64 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 22 Dec 2011, 03:19 PM
I would like to do some server-side manipulation of RadDocuments created in Silverlight (remove header and footer specifically). I have a standard .net assembly referencing the Telerik.Windows.Documents assemblies from the WPF Q3. I get an exception on Export. Am I doing something wrong - or is this simply unsupported? This same code works fine in SL.


var docs = EntityManager.FindEntities(EntityState.Added | EntityState.Modified).OfType<Document>();
			docs.ForEach(
				d =>
					{
						var provider = new XamlFormatProvider();
						var radDocument = provider.Import(d.Content);
						radDocument.Sections.First.Headers.Default = new Header();
						radDocument.Sections.First.Footers.Default = new Footer();
						d.Content = provider.Export(radDocument);
					});


_message "The type initializer for 'Telerik.Windows.Documents.Layout.RadTextMeasurerSL' threw an exception."
+ _innerException {"The calling thread must be STA, because many UI components require this."} System.Exception {System.InvalidOperationException}



5 Answers, 1 is accepted

Sort by
0
Adam
Top achievements
Rank 1
answered on 22 Dec 2011, 03:26 PM
Never mind. I didn't pay enough attention to the inner exception. It is due to thread being MTA. Sorry.
0
Adam
Top achievements
Rank 1
answered on 22 Dec 2011, 03:48 PM
Me again:

I got the exceptions to go away but it appears the exported document is not compatible with SL because of an "IsDefault" attribute added to the "Style" element by the WPF Xaml Provider.

So, I ask again - am I trying to do something unsupported, or am I doing it wrong?

Thanks!
-Adam
0
Martin Ivanov
Telerik team
answered on 23 Dec 2011, 03:42 PM
Hello Adam,
We couldn't reproduce your problem. Please verify that you are using latest (2011.3.1220) version of both Silverlight and WPF controls. If this doesn't help, you could send us (attached to a support ticket) sample project or document that reproduces the issue so we can investigate it further.
Looking forward to your reply.

Kind regards,
Martin
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Adam
Top achievements
Rank 1
answered on 05 Jan 2012, 05:34 PM
This is strange:

We are using an older version of Silverlight assemblies (2011.3.1116). *BUT* that is the version that the documents were created in. We create and store the xaml in silverlight assemblies, then later open them in a non-silverlight application using the later version (2011.3.1220) of the WPF assemblies.

Wouldn't it stand to reason that the providers would be backwards compatible?

0
Adam
Top achievements
Rank 1
answered on 05 Jan 2012, 07:22 PM
Never mind again. One of the other telerik dlls in the project was behind versions. Sorry! Everything works.
Tags
RichTextBox
Asked by
Adam
Top achievements
Rank 1
Answers by
Adam
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or