We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

System.NullReferenceException while creating new workbook

Hi Team,

I’m getting an NullReferenceException while creating new Workbook. Kindly help me through this issue.

Aspose version : 7.5.1.0

Stack Trace :
at . . (String , Int32 , FontStyle )
at . . (WorksheetCollection )
at Aspose.Cells.WorksheetCollection. ()

at Aspose.Cells.WorksheetCollection…ctor(Workbook )
at Aspose.Cells.Workbook…ctor()
at MemberCentre.Services.Core.Documents.UnitPrice.UnitPriceDocumentProcessor.GenerateDocument(String planCode, DateTime filterDate, List`1 investmentOption, Plan plan, String documentTemplatePath, String documentPath, String fileType) in c:\ProjectSpace\MC\Project Member Centre\Features\17.11BAU\MemberCentre.Services\Core\Documents\UnitPrice\UnitPriceDocumentProcessor.cs:line 98

Capture1.PNG (14.6 KB)
Capture.PNG (22.6 KB)

Thanks in advance,
Syed

@Syed_Akram_Ahmed,

Thanks for the error trace and screenshots.

We could not reproduce the issue on our end. Could you create a simple sample VS.NET project (having a single line of code, i.e., var workBook = new Aspose.Cells.Workbook(): ), zip the project and post us here to reproduce the issue on our end, we will check it soon.

Thank you.

Hi Amjad,

I have tested with sample web application. Still i’m getting same exception.

Application : AsposeTest.zip (2.6 MB)

Snapshot : Capture3.PNG (45.9 KB)

StackTrace :

at . . (String , Int32 , FontStyle )
at . . (WorksheetCollection )
at Aspose.Cells.WorksheetCollection. ()
at Aspose.Cells.WorksheetCollection…ctor(Workbook )
at Aspose.Cells.Workbook…ctor()
at AsposeTest.WebForm1.btnWork_Click(Object sender, EventArgs e) in c:\Sample\AsposeTest\AsposeTest\WebForm1.aspx.cs:line 20
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Regards,
Syed

@Syed_Akram_Ahmed,

Thanks for the sample project.

Since your underlying .NET framework version of your project is 4.5, so you should use .NET 4.0 compiled version of Aspose.Cells.Dll. I am not sure if you got .NET 4.0 compiled version for v7.5.x. However in newer versions we do provide .NET 4.0 compiled version of the assembly which works fine for the projects/solutions whose target .NET framework version is 4.5. I think you may first try to use Aspose.Cells.Dll from net2.0 folder if it works fine otherwise, I am afraid, there is no alternative to your problem except you upgrade to latest APIs set of Aspose.Cells and use Aspose.Cells.Dll from net4.0 folder @ your installation directory. Please find your updated project which I compiled with Aspose.Cells.Dll (v17.8 ) from net4.0 folder, it works fine and I do not find any exception whatsoever, see the screenshot for your reference:
screenshot.png (5.3 KB)

Thank you.

HI Amjad,

I have changed my framework version to 4.0 and changing from version 7.5.1 to latest version will there be any impact in existing Aspose functionalities ?

Regards,
Syed

@Syed_Akram_Ahmed,

Good to know that your issue is sorted out now. And, absolutely not, we have even included more enhancements for existing features and fixes in the latest APIs set of the component. Furthermore, there might be certain cases, where you might need to update your existing code segments (in your project) a bit. We recommend you to kindly see the latest APIs reference pages and Docs of Aspose.Cells for .NET for reference.

Thank you.