This is a migrated thread and some comments may be shown as answers.
Ajax callback error when using Custom Progress
3 Answers 69 Views
This is a migrated thread and some comments may be shown as answers.
Charlie Bross
Top achievements
Rank 1
Charlie Bross asked on 30 Oct 2008, 06:46 PM
I am using the RadUpdate/ProgressArea control to allow a user to upload a file and then view the status of the import process. The first progress bar is handled automatically during the update process by the progress area. The second part of the process, the import, I am using the secondary progress bar to give them feedback (processing line x of y).

************* ERROR MESSAGE *****************

RadUpload Ajax callback error. Source url returned invalid content:

var rawProgressData = {InProgress:true,ProgressCounters:true,PrimaryPercent:'100'System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.KeyCollection.Enumerator.MoveNext()
   at Telerik.Web.UI.Upload.ProgressData.Serialize(TextWriter writer)
   at Telerik.Web.UI.RadProgressContext.Serialize(TextWriter writer)
   at Telerik.Web.UI.RadUploadProgressHandler.ProcessRequest(HttpContext context)

Telerik.RadUploadProgressHandler.ashx?RadUrid=9ab592e1-0d6a-43f2-8f5e-9eddc5e20105

Did you register the RadUploadProgressHandler in web.config?

Please, see the help for more details: RadUpload for ASP.NET Ajax - Configuration - RadUploadProgressHandler.

***************** End of Error ******************


Any ideas what is causing this?

Thanks!




**************** Sample Code ********************
UploadedFile file = UploadedFile.FromHttpPostedFile(Request.Files[0]);

string fileName = MapPath("uploads") + "\\" + file.GetName();

file.SaveAs(fileName, true);

if (!Object.Equals(file, null))
{
     importFile(fileName);
}


 private void importFile(string fileName)
    {
        ArrayList lines = new ArrayList();

        RadProgressContext progress = RadProgressContext.Current;
        DateTime startTime = DateTime.Now;

        progress.SecondaryTotal = 100;
        progress.SecondaryValue = 0;
        progress.SecondaryPercent = 0;
        progress.CurrentOperationText = "Reading File..";

        StreamReader reader = new StreamReader(fileName);

        try
        {
            int totalLines = 0;

            while (!reader.EndOfStream)
            {
                totalLines++;
                lines.Add(reader.ReadLine());
            }
            
            progress.SecondaryTotal = totalLines;
            progress.CurrentOperationText = "Importing Data...";

            for (int line = 0; line < totalLines; line++)
            {
                    //progressContext.PrimaryPercent = (int)Math.Round(((decimal)i / count) * 100, 0);
                    progress.SecondaryValue = line;
                    progress.CurrentOperationText = "Importing Data...(" + line + " of " + totalLines + ")";

                TimeSpan elapsed = DateTime.Now.Subtract(startTime);
                progress.TimeElapsed = string.Format("{0:D2}:{1:D2}:{2:D2} s", elapsed.Hours, elapsed.Minutes, elapsed.Seconds);

                double estimatedMillisecons = 24 * 60 * 60 * 1000;
                if (line != 0)
                {
                    estimatedMillisecons = totalLines * elapsed.TotalMilliseconds / line;
                }
                TimeSpan estimated = TimeSpan.FromSeconds(1);
                if (estimatedMillisecons > 1)
                {
                    estimated = TimeSpan.FromMilliseconds(estimatedMillisecons);
                }
                progress.TimeEstimated = string.Format("{0:D2}:{1:D2}:{2:D2} s", estimated.Hours, estimated.Minutes, estimated.Seconds);

                double speed = 0.0d;
                if (elapsed.TotalSeconds > 0)
                {
                    speed = line / elapsed.TotalSeconds;
                }
                progress.Speed = string.Format("{0:0.00} steps/s", speed);

                if (!Response.IsClientConnected)
                {
                    //Cancel button was clicked or the browser was closed, so stop processing
                    break;
                }
            }
        }
        catch (Exception ex)
        {
            App.ProcessException(this, ex);
            throw ex;
        }
        finally
        {
            if (reader != null)
                reader.Close();
        }
    }   


3 Answers, 1 is accepted

Sort by
0
Erjan Gavalji
Telerik team
answered on 02 Nov 2008, 02:30 PM
Hi Charlie,

Thanks for reporting that! Indeed, the error message is a small bug in the serialization of the RadProgressContext object. The bug will be fixed for the official Q3 2008 release of the RadControls for ASP.NET Ajax suite, scheduled for the end of the next week.

Please, bear with us some more.

P.S. Your Telerik account was updated accordingly.

Best regards,
Erjan Gavalji
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
yonigibbs
Top achievements
Rank 1
answered on 18 Mar 2016, 12:00 PM

Hi,

Is the fix for this still available?  A customer of ours is having exactly the same problem, and our software uses the Telerik controls from 2006.

Thanks,

Yoni.

0
Hristo Valyavicharski
Telerik team
answered on 23 Mar 2016, 08:53 AM
Hi Yoni,

You will have to use newer version. We recommend that you upgrade to the latest.

Regards,
Hristo Valyavicharski
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Asked by
Charlie Bross
Top achievements
Rank 1
Answers by
Erjan Gavalji
Telerik team
yonigibbs
Top achievements
Rank 1
Hristo Valyavicharski
Telerik team
Share this question
or