Можно ли использовать WPF DocumentViewer для просмотра документов XPS в .NET 3.5? - PullRequest
0 голосов
/ 05 августа 2011

Я хочу отобразить документ XPS в приложении WinForms, используя компонент WPF DocumentViewer в ElementHost.

Я набрал правильные строки для загрузки файла XPS в Documentviewer:

XpsDocument xpsDoc = new XpsDocument(xpsfile, System.IO.FileAccess.Read);
xpsView.Document = xpsDoc.GetFixedDocumentSequence();

Проблема в том, что я получаю следующее исключение и стек вызовов:

A first chance exception of type 'System.TypeLoadException' occurred in mscorlib.dll

Additional information: Could not load type 'System.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

Может ли это быть связано с реквизитом Net 4.0? Мне нужно нацелиться на 3,5 для этого проекта. XPS ReachFramework доступен с версии 3.0, но я не знаю, где искать.

Спасибо заранее.

...