DivideByZeroException

Thread is closed for posting
12 posts, 0 answers
  1. John Landeborg
    John Landeborg avatar
    4 posts
    Member since:
    Dec 2009

    Posted 28 Dec 2010 Link to this post

    RadUpload Ajax callback error
    ...
    RadUploadContext.GetProgressData()

    The error is intermittent and occur before progressbar is visible.

    It's a customer’s production server that I have no access to, so I have no server logs available etc. It look likes the response time is slow. Compare with other installations the time between I submit a file and to the progress is displayed is longer.

    Is it possible that UploadedFile property ContentLength return 0?

    if (RadUpload.UploadedFiles.Count > 0)
    {
      uploadedFile = RadUpload.UploadedFiles[0];
      totalSize = uploadedFile.ContentLength;
    }

    do
    {
                            bytesRead = reader.Read(buffer, 0, readChunkSize);
                            ms.Write(buffer, 0, bytesRead);
                            processedSize += bytesRead;
                            percent = (int)((processedSize / totalSize) * 100);
                            progress["SecondaryTotal"] = total.ToString();
                            progress["SecondaryValue"] = percent.ToString();
                            progress["SecondaryPercent"] = percent.ToString();
                            progress["CurrentOperationText"] = fileReadingMsg;
    } while (bytesRead != 0);


    Any suggestions?
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 03 Jan 2011 Link to this post

    Hi John Landeborg,

    It is unlikely that an uploaded fie will arrive at the server with ContentLentgth of zero, at least we haven't heard of similar reports from other clients. Is the error breaking the progress functionality? If no, you can suppress it, however, I need the exact error in order to provide you with the needed script. Apart from this, indeed the time between pressing the submit button and when the area is actually shown, is determined by the time it takes for the request to the progress area handler to return response. I am wondering whether you are not facing a timeout issue. Can you please paste a the detailed error here? A screenshot will also be of help.



    Kind regards,
    Genady Sergeev
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. John Landeborg
    John Landeborg avatar
    4 posts
    Member since:
    Dec 2009

    Posted 03 Jan 2011 Link to this post

    Thanks!

    Because the error arise so rarely I have not had opportunity to catch a error message.. yet.. But one error report send to me (by Skype) is here:

    RadUpload Ajax callback error. Source url returned invalid content: System.DivideByZeroException: Det gjordes ett försök att dividera med noll. vid System.Decimal.FCallDivide(Decimal& d1, Decimal& d2) vid Telerik.Web.UI.RadUploadContext.PopulateProgressData(RadUploadProgressData progressData) vid Telerik.W

    Skype truncated the message….

    The other time was by a webuser that did a print + scan + mail thing, so it looks terrible. But her it is…

    And yes. The error breaks the upload and no progress is shown. Should I realy catch and ignore the error?

  5. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 06 Jan 2011 Link to this post

    Hello John Landeborg,

    This is really strange problem. I suggest that you bullet proof your code against Division By Zero exception, for example you can check whether totalSize is bigger than zero. To be honest I can't think of a possible reason for file size being zero, perhaps it is a very rare issue that we haven't faced yet. In general I think that bullet proofing your code would do the job.

    Regards,
    Genady Sergeev
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  6. John Landeborg
    John Landeborg avatar
    4 posts
    Member since:
    Dec 2009

    Posted 26 Jan 2011 Link to this post

    I have correct the code and check if size is zero, so the error should not occur and the user have to try to upload the file again. But the file is not zero, so the mystery remains! I have been able since last to read event - and iis-loggfiles. No conclusive result. The best guess yet is some kind of timeout due bad response time. Only 1 error report since last and this time I received a nice screenshot.
  7. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 31 Jan 2011 Link to this post

    Hello John Landeborg,

    I was thinking about increasing the time before a request would time out. Please take a look at this MSDN topic, which presents the httpRuntime element in web.config. You can use its executionTimeout property in order to set timeout timespan for a web request.


    Kind regards,
    Genady Sergeev
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  8. Lakshmi Satish Maddela
    Lakshmi Satish Maddela avatar
    5 posts
    Member since:
    Jun 2008

    Posted 23 Sep 2011 Link to this post

    Hi,
        I am also facing similar type of error, but could not get a resolution to the issue. Please let me know in case of any suggestions.I am attaching the screenshot here.
  9. John Landeborg
    John Landeborg avatar
    4 posts
    Member since:
    Dec 2009

    Posted 23 Sep 2011 Link to this post

    Check uploadeFile.ContentLengt is >0 before divide. But is it rely 0 no file is uploaded… Probably a timeout issue, so check web.config settings like something like:

    <httpRuntime maxRequestLength="2000000" executionTimeout="600"/>

  10. Douglas R.
    Douglas R. avatar
    4 posts
    Member since:
    Sep 2007

    Posted 10 Oct 2012 Link to this post

    An uploaded file will have a context length of zero when the user types in the name of a file that does not exist.  For example,

    d:\context length zero.jpg
  11. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 15 Oct 2012 Link to this post

    Hi Douglas,

    I've tried to reproduce the problem on our online demos, however, no avail. The FileDialong did correctly moan that such file does not exist. However, we might be missing something obvious. Could you please record a short video demonstrating how to reproduce the problem?

    All the best,
    Genady Sergeev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  12. Douglas R.
    Douglas R. avatar
    4 posts
    Member since:
    Sep 2007

    Posted 15 Oct 2012 Link to this post

    Version 2.4.6 (RadUpload.Net2.DLL) doesn't force the user to use the file open dialog -- they can type a file name into the input box.
  13. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 18 Oct 2012 Link to this post

    Hi John,

    It seems that you are using the classic controls, which are no longer supported and are likely to have issues, especially with the modern browsers. I suggest that you update to the ASP.NET Ajax controls as a resolution for the problem.

    Greetings,
    Genady Sergeev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017