Free Support Forum - aspose.com

Error trapping

Hi,

I have installed the evaluation of .Cells on my laptop and my web server. The code works fine on my laptop, but the same code is throwing a generic Exception on my web server. Can you show me some more specific error trapping example? I believe the error is occurring when I try and open a workbook located on a different server:

Workbook workbook = new Workbook(); // the Aspose workbook object

try

{

workbook.Open(ViewState["FilePath"].ToString(), FileFormatType.Excel2003);

}

catch (Exception)

{

return false;

}

Thanks.

Hi,

Which version do you use? Please try the attached fix. If you still get the exception,please post your template file.

Thanks, but the new .dll doesn't help. It works fine on my dev laptop with Cassini, but not on our web server. I was hoping you could send me some code that show what exceptions might be thrown so I can catch them and troubleshoot them. I am using version 4.4.1.14, the one in your attachment.

Nothing shows in the event log on the web server related to the application.

What template file are you looking for?

Also, it works on the web server if the workbook I need to open is on the webserver. If it's on a different server (which is the goal), it doesn't work. So maybe it's a permissions thing?

Hi.

Yes, I think it might be configuration / permission issue, kindly assign proper rights for the server and then try it.

Thank you.

Yup, it turns out to be a permission issue. I can open the workbook if it's on the server, but not if it's on a different server. So we are asking our server monkeys to grant the appropriate permissions to the servername\ASPNET user.

Back to my original question. Your docs don't give much guidance on the different errors that a workbook object (for example) can throw. I can catch an original .NET Exception, but do you have any samples on what errors could be thrown by your objects/methods? Thanks.

Hi,

Well, Aspose.Cells is a pure .NET component so the exceptions occured for the different operations / processes are the same as .NET exceptions i.e. all excptions are derived from Exception class. And Aspose.Cells provides its own CellsException class which inherits System.Object and System.Exception classes on the upper level and it has defined custom exception(s).

e.g.., If you open an html file into notpad and save it as .xls file, a CellsException would be thrown stating that "the file's format is not supported or you don't specify correct format".

Sample code:

Workbook workbook = new Workbook();

try
{
workbook.Open("d:\\test\\nonnativefile.xls");
}
catch(Aspose.Cells.CellsException ee)
{
MessageBox.Show(ee.Message);
}

Thank you.

Thanks, Amjad. The CellsException class is what I was looking for.