- Home
- Forum
- ASP.NET Web Forms (Classic)
- NullReferenceException
NullReferenceException
I have an app where I am experiencing random NullReferenceExceptions in the Finalize method of the ExcelEngine, as well as numerous other random and impossible to consistently reproduce Syncfusion exceptions.
I created some sample code which throws a NullReferenceException on the Workbook.Close.
When the ExcelEngine is moved to the class level alongside the workbook object, the problem goes away.
This is not exactly the same issue as I am experiencing but I thought it might be related.
I noticed in some of the Syncfusion sample code that they are declaring the ExcelEngine inside a function and then returning a workbook/worksheets from that function. I assume then that I should in theory be able to let my ExcelEngine go out of scope and still be able to use my Workbook and vice versa? I experience problems with my app regardless of whether I am calling Dispose methods and setting objects to nothing after use.
This is happening with version 6.2 and with the previous version.
SyncfusionBug.zip
I created some sample code which throws a NullReferenceException on the Workbook.Close.
When the ExcelEngine is moved to the class level alongside the workbook object, the problem goes away.
This is not exactly the same issue as I am experiencing but I thought it might be related.
I noticed in some of the Syncfusion sample code that they are declaring the ExcelEngine inside a function and then returning a workbook/worksheets from that function. I assume then that I should in theory be able to let my ExcelEngine go out of scope and still be able to use my Workbook and vice versa? I experience problems with my app regardless of whether I am calling Dispose methods and setting objects to nothing after use.
This is happening with version 6.2 and with the previous version.
SyncfusionBug.zip
SIGN IN To post a reply.
7 Replies
SA
Sarah
May 23, 2008 05:39 AM UTC
I'll just add that I ran the sample code again several times this afternoon with the following results:
On one occasion the code worked.
On several other occasions I got the NullReferenceException again (seems to happen particularly when I set a breakpoint on the Workbook.Close)
On other occasions I got a variety of different errors.
On one occasion the code worked.
On several other occasions I got the NullReferenceException again (seems to happen particularly when I set a breakpoint on the Workbook.Close)
On other occasions I got a variety of different errors.
YG
Yavanaarasi G
Syncfusion Team
May 26, 2008 11:44 AM UTC
Hi Sarah,
Thank you for your interest in Syncfusion products.
I am able to see the issue that you have mentioned. But the issue is not because of XlSIO. The issue reproduced only with your sample. Your class file can be called wrongly. I have created a new sample with class file and called the function here no exception thrown. Please refer the sample in the below link:
http://websamples.syncfusion.com/samples/XlSIO.Web/6.2.0.40/F-73864/Syncfusionsample.zip
Please try to check your code and let me the issue still exists.
Regards,
G.Yavana
Thank you for your interest in Syncfusion products.
I am able to see the issue that you have mentioned. But the issue is not because of XlSIO. The issue reproduced only with your sample. Your class file can be called wrongly. I have created a new sample with class file and called the function here no exception thrown. Please refer the sample in the below link:
http://websamples.syncfusion.com/samples/XlSIO.Web/6.2.0.40/F-73864/Syncfusionsample.zip
Please try to check your code and let me the issue still exists.
Regards,
G.Yavana
SA
Sarah
May 27, 2008 06:49 AM UTC
Thanks, but I am wondering why the name of my class would be relevant to Xlsio?
It seems you changed the case of the class and one of the functions? I tried changing this in my own sample project and it now works most but not all of the time. I also found I can change the class name back again and it will continue to work (most of the time).
The sample project you sent me is still giving me the same exceptions. Occasionally, it will also work for a while.
I think the renaming of the class is having some side effect which is temporarily causing the problem to go away, but I don't think it is the root cause of the problem. Also note that the classes in my real app have different names and still experience the problem.
Thanks
It seems you changed the case of the class and one of the functions? I tried changing this in my own sample project and it now works most but not all of the time. I also found I can change the class name back again and it will continue to work (most of the time).
The sample project you sent me is still giving me the same exceptions. Occasionally, it will also work for a while.
I think the renaming of the class is having some side effect which is temporarily causing the problem to go away, but I don't think it is the root cause of the problem. Also note that the classes in my real app have different names and still experience the problem.
Thanks
YG
Yavanaarasi G
Syncfusion Team
May 28, 2008 12:48 PM UTC
Hi Sarah,
It seems like another forum that you are created regarding this issue. Could you please provide the stack trace for this issue also?
Regards,
G.Yavana
It seems like another forum that you are created regarding this issue. Could you please provide the stack trace for this issue also?
Regards,
G.Yavana
SA
Sarah
May 29, 2008 12:27 AM UTC
Details of the exception(s) in relation to this issue are attached. This is a seperate issue to my other post. Thanks
Error Details.zip
Error Details.zip
YG
Yavanaarasi G
Syncfusion Team
May 29, 2008 11:46 AM UTC
Hi Sarah,
Thank you for providing the details.
We have forwarded the stack trace to our development team. Also please provide the sample image it will be helpful to reproduce the issue in our side.
Regards,
G.Yavana
Thank you for providing the details.
We have forwarded the stack trace to our development team. Also please provide the sample image it will be helpful to reproduce the issue in our side.
Regards,
G.Yavana
JH
JiSoo Hong
March 15, 2010 06:57 AM UTC
Hi there,
VERSION: Syncfusion Essential Studio User Interface 2009 Vol 4 (V7.4.0.20)
I am trying to make an excel file using ExcelEngine.
In my computer (Win XP), it works FINE.
However, I got an exception error as attached through the WEB SERVER(WIN 2003 Server).
I copied the following files in the bin directory of WEB SERVER:
Syncfusion.Core.dll
Syncfusion.Compression.Base.dll
Syncfusion.xlsio.base.dll
Syncfusion.xlsio.Web.dll
Again, Syncfusion and MS Excel are not installed in the WEB SERVER. (Is it OK??)
The following is a sample code I tried.
============== source code =======
private void ExportExcel()
{
//A new instance of Excel Application is created
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
//A new workbook object is created
IWorkbook myWorkbook = excelEngine.Excel.Workbooks.Add();
IWorksheet mySheet = myWorkbook.Worksheets[0];
mySheet.Name = "Weekly";
int i, j;
for (i = 1; i <= 20; i++)
{
for (j = 1; j <= 20; j++)
{
IRange xlRange = mySheet.Range[i, j];
xlRange.Value = string.Format("({0}, {1})", i, j);
}
}
string sXlFileName = "test.xls";
myWorkbook.SaveAs(sXlFileName, ExcelSaveType.SaveAsXLS, Response, ExcelDownloadType.PromptDialog);
}
===================================
Thanks in advance.
Hong
Result_60cbd4f6.zip
VERSION: Syncfusion Essential Studio User Interface 2009 Vol 4 (V7.4.0.20)
I am trying to make an excel file using ExcelEngine.
In my computer (Win XP), it works FINE.
However, I got an exception error as attached through the WEB SERVER(WIN 2003 Server).
I copied the following files in the bin directory of WEB SERVER:
Syncfusion.Core.dll
Syncfusion.Compression.Base.dll
Syncfusion.xlsio.base.dll
Syncfusion.xlsio.Web.dll
Again, Syncfusion and MS Excel are not installed in the WEB SERVER. (Is it OK??)
The following is a sample code I tried.
============== source code =======
private void ExportExcel()
{
//A new instance of Excel Application is created
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
//A new workbook object is created
IWorkbook myWorkbook = excelEngine.Excel.Workbooks.Add();
IWorksheet mySheet = myWorkbook.Worksheets[0];
mySheet.Name = "Weekly";
int i, j;
for (i = 1; i <= 20; i++)
{
for (j = 1; j <= 20; j++)
{
IRange xlRange = mySheet.Range[i, j];
xlRange.Value = string.Format("({0}, {1})", i, j);
}
}
string sXlFileName = "test.xls";
myWorkbook.SaveAs(sXlFileName, ExcelSaveType.SaveAsXLS, Response, ExcelDownloadType.PromptDialog);
}
===================================
Thanks in advance.
Hong
Result_60cbd4f6.zip
SIGN IN To post a reply.
- 7 Replies
- 3 Participants
-
SA Sarah
- May 23, 2008 01:06 AM UTC
- Mar 15, 2010 06:57 AM UTC