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

Free Support Forum - aspose.com

GridWeb System.NullReferenceException for certain users

I have a GridWeb control embedded on an ASPX web page. I do not always need to display an Excel spreadsheet, so I will set the .Visible property on the control to "false." For almost all users, this works just fine: the GridWeb is not displayed and the rest of the web page content displays just fine. But some portion of users receive the following error message:

System.NullReferenceException: Object reference not set to an instance of an object. at Aspose.Cells.GridWeb.GridWeb.
OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

I have not been able to reproduce the problem on my own workstations; it seems to only occur for certain web users, but I am not sure what browser / configuration they are using. They are accessing the same web page, same content, same code from our servers. They are accessing pages with no Excel content on them.

Snippets of code:

.aspx page

<%@ Register TagPrefix="acw" Namespace="Aspose.Cells.GridWeb" Assembly="Aspose.Cells.GridWeb" %>





.aspx.cs page

if (OpenWithExcel())
{
Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense("Aspose.Total.lic");

Aspose.Cells.GridWeb.License license2 = new Aspose.Cells.GridWeb.License();
license2.SetLicense("Aspose.Total.lic");

GridWeb1.Visible = true;
GridWeb1.WebWorksheets.Clear();
GridWeb1.WebWorksheets.ImportExcelFile(_filePath);
GridWeb1.EditMode = false;
}
else
{
//do something else on this page, GridWeb1 stays Visible = false;
}

Hi,

Well, it looks really strange as you got the issue for very few users. I am afraid, we need a sample demo project, zip it and post it here to reproduce the issue on our end.

Also, which version of the product your are using. We also recommend you to try our latest version i.e. Aspose.Cells for .NET (Latest Version)

Thank you.

Here is a sample project that I have created. There is a somewhat unusual structure that mimics what we are doing in the actual application. Default.aspx includes a UserControl called CoursePage.ascx, and CoursePage.ascx includes a UserControl called FileViewer.ascx.


There are three links on Default.aspx. All will provide data to CoursePage.ascx, but only two of the links will set the FileViewer control visible = true. The file could be an Excel file, in which case the GirdWeb control is shown, or the file could be a Word document, and the GridWeb is not shown, or there could be no file, and the FileViewer control itself will have its visibility set to false.

We are seeing errors for some users relating to GridWeb on both the link that would show the Word file and the link that should not show any files.

As I said, it only seems to affect certain users. The project and our live application work perfectly on our workstations and for the majority of users, but certain users get an error every time.

Hi,

Will you please check if the error is occurring on certain browsers like firefox, IE etc. Also mention the browser versions being used by your clients. If it is IE and later than 7.0, is it being used in compatibility view etc.