Bad IL format exception

Stimulsoft Reports.NET discussion
Post Reply
Lotte
Posts: 3
Joined: Tue Dec 10, 2013 2:42 pm

Bad IL format exception

Post by Lotte »

Hi,

A customer is running our software (Windows Forms with StimulReports 2014.1.1900.0) and gets a "Bad IL Format" exception when trying to print a report or open it in the report viewer control for windows forms.

I'm using your reporting tools already for several years and have never encountered this exception.

Can you point us in the right direction which might be the problem?

Here is the stacktrace:

InnerException message : Could not load file or assembly '0 bytes loaded from System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Begin StackTrace
------------------------------------------
at System.Reflection.RuntimeAssembly.nLoadImage(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark& stackMark, Boolean fIntrospection, SecurityContextSource securityContextSource)
at System.Reflection.Assembly.Load(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence securityEvidence)
at Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch(CompilerParameters options, String[] fileNames)
at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources)
at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources)
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters options, String[] sources)
at Stimulsoft.Base.StiCompiler.Compile(String textToCompile, String outputAssembly, LanguageType languageType, StiOutputType outputType, String[] referencedAssemblies, List`1 resources)
at Stimulsoft.Report.StiReport.Compile(String path, Stream stream, StiOutputType outputType, Boolean autoCreate, Object standaloneReportType)
at Stimulsoft.Report.StiReport.Compile()
at Stimulsoft.Report.Engine.StiReportV2Builder.RenderSingleReport(StiReport masterReport, StiRenderState renderState)
at Stimulsoft.Report.StiReport.RenderReport(StiRenderState renderState)
at Stimulsoft.Report.StiReport.Render(StiRenderState renderState, StiGuiMode guiMode)
at Stimulsoft.Report.StiReport.Render()
at BIG.Products.GUI.ProductViewer.frmPrint.ShowReportPreview(StiReport report)
at BIG.Products.GUI.ProductViewer.frmPrint.PrintReport(Boolean showPreview)
at BIG.Products.GUI.ProductViewer.frmPrint.btnPreview_Click(Object sender, EventArgs e)
------------------------------------------
End StackTrace

InnerException message : Bad IL format.
Begin StackTrace

Hope someone knows what is the cause of this issue?

Thanks.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Bad IL format exception

Post by HighAley »

Hello.

Sorry, but we don't know why do you get this error.
Please, try to read answers on the Why return BAD IL FORMAT to load assembly from wcf service? question.
If this does not help, please, send us a sample project which reproduces the issue.

Thank you.
Lotte
Posts: 3
Joined: Tue Dec 10, 2013 2:42 pm

Re: Bad IL format exception

Post by Lotte »

Hi,

As you pointed out in your link, I assumed that loading the dynamically generated assembly gives the error.

However, it happens when stimulsoft generates the assembly from the .mrt file. I guess the Stimulsoft .CSharpCodeGenerator.FromFileBatch generates code that can't be read by the consecutive Assembly.Load. Does the generator store the generated assembly in a temporary folder where there could be access issues or something? What does the code generator need as requirements to function properly and make the assembly work?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Bad IL format exception

Post by HighAley »

Hello.

Yes, there could be an access problem. You could change the path to compiled report by adding a parameter to the Compile method.

Code: Select all

 report.Compile(compiledReportFile);
You could solve the issue by specifying a folder that application has access to.

Thank you.
Lotte
Posts: 3
Joined: Tue Dec 10, 2013 2:42 pm

Re: Bad IL format exception

Post by Lotte »

Thank you for the information.

However the affected user reported that the issue was solved. He thinks it was solved after he updated the .NET framework from 4.5.1 to 4.5.2 and rebooted the server in the process.

I don't know if the server reboot or the .NET framework update did it, but for now the issue is solved.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Bad IL format exception

Post by Alex K. »

Hello,

We are always glad to help you!
Let us know if you need any additional help.

Thank you.
Post Reply