Can WPF DocumentViewer be used to view XPS documents with .NET 3.5?
I want to display a XPS document in a WinForms application using the WPF DocumentViewer component in an ElementHost.
I've typed the correct lines to load the XPS file into the Documentviewer:
XpsDocument xpsDoc = new XpsDocument(xpsfile, System.IO.FileAccess.Read);
xpsView.Document = xpsDoc.GetFixedDocumentSequence();
The problem is that I'm getting the following exception and callstack:
A first chance exception of type 'System.TypeLoadException' occurred in mscorlib.dll
Additional information: Could not load type 'Syst开发者_运维问答em.Runtime.Versioning.TargetFrameworkAttribute' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
mscorlib.dll!System.ModuleHandle.ResolveTypeHandle(int typeToken, System.RuntimeTypeHandle[] typeInstantiationContext, System.RuntimeTypeHandle[] methodInstantiationContext) + 0x94 bytes
mscorlib.dll!System.Reflection.Module.ResolveType(int metadataToken = 16777295, System.Type[] genericTypeArguments, System.Type[] genericMethodArguments) + 0xcc bytes
mscorlib.dll!System.Reflection.CustomAttribute.FilterCustomAttributeRecord(System.Reflection.CustomAttributeRecord caRecord, System.Reflection.MetadataImport scope, ref System.Reflection.Assembly lastAptcaOkAssembly = null, System.Reflection.Module decoratedModule = {System.Reflection.Module}, System.Reflection.MetadataToken decoratedToken = {System.Reflection.MetadataToken}, System.RuntimeType attributeFilterType = {Name = "XmlnsDefinitionAttribute" FullName = "System.Windows.Markup.XmlnsDefinitionAttribute"}, bool mustBeInheritable = false, object[] attributes = {System.Windows.Markup.XmlnsDefinitionAttribute[15]}, System.Collections.IList derivedAttributes = null, out System.RuntimeType attributeType = null, out System.RuntimeMethodHandle ctor = {System.RuntimeMethodHandle}, out bool ctorHasParameters = false, out bool isVarArg = false) + 0x86 bytes
...
...
...
PresentationFramework.dll!System.Windows.Markup.XamlParser.Parse() Line 218 + 0x8 bytes C#
PresentationFramework.dll!System.Windows.Markup.XamlTreeBuilder.ParseFragment() Line 134 + 0xa bytes C#
PresentationFramework.dll!System.Windows.Markup.TreeBuilder.Parse() Line 70 + 0x7 bytes C#
PresentationFramework.dll!System.Windows.Markup.XamlReader.XmlTreeBuildDefault(System.Windows.Markup.ParserContext pc, System.IO.Stream stream, System.Windows.Markup.XamlParseMode parseMode, bool etwTracingEnabled) Line 806 + 0x7 bytes C#
PresentationFramework.dll!System.Windows.Markup.XamlReader.Load(System.IO.Stream stream, System.Windows.Markup.ParserContext parserContext) Line 297 + 0x3b bytes C#
ReachFramework.dll!System.Windows.Xps.Packaging.XpsDocument.GetFixedDocumentSequence() + 0xdf bytes
Could this be related to the Net 4.0 requeriment? I need to target 3.5 for this project. XPS ReachFramework is available since 3.0 but I don't know where to look.
THanks in advance.
精彩评论