System.BadImageFormatException When trying to open the Presentation File

I am developing an ASP.NET 5 MVC application. I have the Syncfusion.Presentation.AspNet.Mvc5 NuGet package version 19.2.0.55.

I have referenced using Syncfusion.Presentation; in the top section of the code.

I am running into a error when trying to open the presentation file

 IPresentation srcPres = Presentation.Open(@"C:\RAPiD_Web\RAPiD_Web\Base\Slide Library\K3 Intro.pptx")

Error:

System.BadImageFormatException: 'Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (0x80131058)'

At first I didn't have the license key set. So, I got that generated and added to my Startup.cs as the first thing under Configure. 

But this error is still happening.




4 Replies

MR Manikandan Ravichandran Syncfusion Team October 1, 2021 10:06 AM UTC

Hi Edward,

Thank you for contacting Syncfusion support.

We have tried to reproduce the reported problem using the given details, but it is working fine in our end. For your reference, we have attached the Asp.Net MVC sample which is used at our end to reproduce the problem. Could you please check this sample at your end and share the simple sample along with input presentation document if you still facing the issue.

Sample link:
https://www.syncfusion.com/downloads/support/forum/169294/ze/ASPNetMVC_F1692941595205936

Please let us know if you have any other queries.

Regards,
Manikandan Ravichandran 



EW Edward Williams October 1, 2021 01:11 PM UTC

Okay, looking at the NuGet packages, I see the exclamation next to the Syncfusion.Presenation.AspNet.Mvc5 package.

I have added the Syncfusion.Licensing as I did not have that before. I see in the warning message that this particular version 19.2.0.55 may not be compatible with .net5.0.

I had originally told my POC there at Syncfusion that I had already created a full web application (MVC) with Azure authentication using the new .net5.0 framework. I asked him if I could just add in the Syncfusion functionality or if I have to start a whole new application from scratch. He said that I could just add it to my existing one. However, now I am seeing possible issues.

My trial license is for the 19.2.0.55 version of the packages. I'm wondering if it may not be compatible with the .net5.0 framework....

Or maybe I'm missing other packages or have the wrong one.

Screenshot 2021-10-01 060924.pngScreenshot 2021-10-01 061105.png



MR Manikandan Ravichandran Syncfusion Team October 4, 2021 12:51 PM UTC

Hi Edward,

Thank you for your update.

From the given details, we have found that you are using .net 5.0 targeted application in your end. For this application, you should use the Syncfusion.Presentation.Net.Core packages to run the application.



Please refer the below link to know more about NuGet packages required for each platform.
https://help.syncfusion.com/file-formats/presentation/nuget-packages-required

If you still facing any issues means, then share the simple sample along with input document and complete details about the issue which will be helpful for us to investigate further on this.

Please let us know if you have any other queries.

Regards,
Manikandan Ravichandran 



EW Edward Williams October 4, 2021 01:56 PM UTC

Looks like that was it. Thanks!


Loader.
Up arrow icon