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

Exception about can't find OpenXml.dll when trying to render to PDF

1 Answer 544 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 18 Oct 2013, 08:13 PM
I have this code:
ReportProcessor reportProcessor = new ReportProcessor();
Hashtable deviceInfo = new Hashtable();
var source = new InstanceReportSource { ReportDocument = report };
RenderingResult result = reportProcessor.RenderReport( "PDF", source, deviceInfo );


On this last line (the RenderReport call) I get this exception:
The type initializer for 'Telerik.Reporting.OpenXmlRendering.Wordprocessing.WordprocessingReport' threw an exception.
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at Telerik.Reporting.Processing.ExtensionManagerBase.CreateExtensionInfo(String typeName, String extensionName)

Which contains an inner exception:
Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.":"DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
   at Telerik.Reporting.OpenXmlRendering.Wordprocessing.WordprocessingReport..cctor()



This was working before I upgraded from Windows 8 to WIndows 8.1. I upgraded to the latest reporting version, which did not help. I am not sure why it is trying to access OpenXml when I am asking it to generate a PDF.

1 Answer, 1 is accepted

Sort by
0
Ivan Hristov
Telerik team
answered on 23 Oct 2013, 09:16 AM
Hello John,

We don't think that this issue has something in common with the upgrade to Windows 8.1.
During the enumeration of the available exporting extension the processing engine tries to load the OpenXML types, regardless that you are exporting to PDF format. If some of the exporting extension assemblies cannot be loaded, a first chance exception is thrown, but this should not affect the behavior of your application.

You can uncheck the "System.IO.FileNotFoundException" under Common Language Runtime Exceptions in your Debug / Exceptions dialog of your Visual Studio in case it is checked. This will prevent the IDE from stopping anytime such an exception is being thrown.

Also you could reinstall the OpenXML SDK from Microsoft and add the binding redirects in your .config file if necessary. You can take a look at this KB article for more information.
 
Regards,
Ivan Hristov
Telerik

Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

Tags
General Discussions
Asked by
John
Top achievements
Rank 1
Answers by
Ivan Hristov
Telerik team
Share this question
or