EndOfStreamException occuring during file upload...

Last post 04-17-2009, 3:12 AM by cutechat. 7 replies.
Sort Posts: Previous Next
  •  04-15-2009, 11:31 AM 51112

    EndOfStreamException occuring during file upload...

    Hi -
     
    We are trying to stream the uploaded file(s) from the upload temp directory to an external location once each file is uploaded.  We have implemented an eventhandler for the OnFileUploaded event in which we do the following...
     
    protected void ajaxUploader_OnFileUploaded(object sender, CuteWebUI.UploaderEventArgs args)
        {
                using (System.IO.Stream uploadedStream = args.OpenStream())
                {
                    try
                    {
                        byte[] fileData = new byte[uploadedStream.Length];
                        uploadedStream.Read(fileData, 0, fileData.Length);
     
                        // stream document to external location and write document meta-data to database
                    }
                    catch (Exception ex)
                    {
                        // Wrap exception to provide additional context...
                        string messageFormat = "An exception occurred uploading a file!  Additional information below:\n\nFileGuid:{0}\nFileName:{1}\nFileSize:{2}\nTempFilePath:{3}";
                        ApplicationException uploadException = new ApplicationException(String.Format(messageFormat, args.FileGuid,
                            args.FileName, args.FileSize, args.GetTempFilePath()), ex);
                       
                        // log the exception (EntLib 3.1)
                        Common.Utility.ProcessUnhandledException(uploadException);
                    }
                    finally
                    {
                        uploadedStream.Close();
                    }
                }        
        }
     
     
    Unfortunately, the EndOfStreamException is doesn't appear to be happening within the event handler and we aren't trying to stream the document anywhere else...  This results in the AjaxUploader control catching the exception and writing the message to an alert box (see below)...
     
     
    The primary question I have to start with is where is this exception being caught so that I can implement the appropriate try/catch to narrow down why this exception is happening...  Having just the exception message written to an alert box doesn't give us enough information to identify why this behavior is occurring.
     
    We have not specified the appsetting to override the UploaderTemp directory and have granted full access to the virtual directory, but the files are never uploaded to the UploaderTemp folder (this is likely the cause of the EndOfStreamException...)
     
    The code above works fine in our DEV environment, but we are running into this exception in our UAT enviroment... being able to log the detailed exception with stacktrace will help us identify any environment configuration issues that we are seeing.
     
    Thanks,
     
    Casey
    Filed under:
  •  04-16-2009, 10:49 AM 51160 in reply to 51112

    Re: EndOfStreamException occuring during file upload...

    Casey,
     
    I am not sure that EndOfStreamException is throwed from your code.
     
    Maybe it is throwed from uploader internal code.
     
    So you can just do a test :
     
    protected void ajaxUploader_OnFileUploaded(object sender, CuteWebUI.UploaderEventArgs args)
    {
          Common.Utility.ProcessUnhandledException(new Exception("My Error"));
    }
     
    Please confirm it.
     
    Regards,
    Terry
  •  04-16-2009, 11:26 AM 51166 in reply to 51160

    Re: EndOfStreamException occuring during file upload...

    Terry -
     
    Yes, that is how we originally verified the enterprise library exception handling was working... 
     
    By implementing simple logging events, I've confirmed this morning that the exception is not occuring within the ajaxUploader_OnFileUploaded eventhandler...  We are not getting any informational event logs that indicate we are even getting into the eventhandler, so the OnFileUpload event may not be fired from within the AjaxUploader control.
     
    Thanks,
    Casey
  •  04-16-2009, 12:01 PM 51167 in reply to 51166

    Re: EndOfStreamException occuring during file upload...

    Casey,
     
    Can you tell me the dotnet framework version or your server??
     
    Regards,
    Terry
     
  •  04-16-2009, 1:00 PM 51171 in reply to 51167

    Re: EndOfStreamException occuring during file upload...

    This is against  .NET v2.0.50727
  •  04-16-2009, 1:05 PM 51172 in reply to 51171

    Re: EndOfStreamException occuring during file upload...

    That's strange. Because I don't see the dotnet2.0 throws that exception.
     
    Anyway , please download the control again, we have improved it.
     
    Regards,
    Terry
  •  04-16-2009, 2:53 PM 51183 in reply to 51172

    Re: EndOfStreamException occuring during file upload...

    Terry -
     
    I don't understand your comment... EndOfStreamException is in the 2.0 framework.
     
    What version of the .NET 2.0 framework is the CuteWebUI.AjaxUploader.dll v2.0.0.0 assembly dependent on?  In other words, is the control dependent on a specific hotfix or service pack install (SP1 / SP2)?  I'm working to verify now, but it appears that the assembly is dependent on at least .NET 2.0 SP1...
     
    I'll look at upgrading the control, but need to understand the dependencies... Does CuteWebUI.AjaxUploader.dll v3.0.0.0 have the same dependencies?

    Thanks,
    Casey
  •  04-17-2009, 3:12 AM 51192 in reply to 51183

    Re: EndOfStreamException occuring during file upload...

    Casey,
     
    I mean , In dotnet1.1 , the FileStream will throws the EndOfStreamException , but dotnet2.0 not .
     
    The CuteWebUI.AjaxUploader.dll have two versions. 
     
    You can get the version for dotnet1.1 from the samples Framework 1.1 Xxxxx
     
    And you can get the version for dotnet2.0 from the samples Framework 2.0 Xxxxx
     
     
    Both the AjaxUploader v2.0.0.0 and v3.0.0.0 do the same thing.
     
    Regards,
    Terry
     
     
View as RSS news feed in XML