(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .

Uploading multiple files with Silverlight

(8 votes)
Andrea Boschin
>
Andrea Boschin
Joined Nov 17, 2009
Articles:   66
Comments:   9
More Articles
27 comments   /   posted on Jul 02, 2010
Categories:   General

This article is compatible with the latest version of Silverlight.

Note from SilverlightShow: this article topic has been requested by Raymond Monette. Thanks Raymond!

There is a control, in the HTML markup, that has not been changed since its first introduction, probably with the first version of the Prince of the markup languages. As you have understand for sure, I'm referring to the <input type="file" /> element that, from many years, is able to implement the file upload process in HTML, but that is so far from being perfect and from give a friendly user experience.

Of course many third party libraries and vendors have built its own controls, to override the problems of this important element of the markup, and many of them have succeeded using AJAX, Flash, and other Rich Internet technologies. In this article I would want to cover this matter, creating a simple reusable control that let the developer to implement a better file-uploading experience using Silverlight.

Download Source Code

Let play some creativity

Watching to the ancestor of the file-upload controls we can see many limitations: first of all, it is able to upload only a single file at a time, and this is a problem since too often there is the need of select many files and send them together to the server (e.g. think at multiple email attachments). Another important concern is about the progress of the upload. When we are sending huge files there is not any feedback about the progress of the work, so the user is not sure the upload is going to end or not. It may seems strange, but it is the main source of pain to me.

Using Silverlight it is possible to create a first-class control with advanced features. So, imagine to implement the control as an area where someone can drag files, many at a time, and then the files are automatically enqueued for the transfer to the server. Of course there is the need to deal some limitations of Silverlight. The plug-in can only make two concurrent call to the server, so the control have to manage this limitation avoiding to overload the network. Another problem is that Silverlight has not any way to be notified of the progress of the upload. Since this is an important feature the only available solution is to break a single file in multiple chunks of data and send them one at a time, updating the progress percentage every time a chunk has been received from the server. This feature is for sure a big complication to the work that has to be done because the server has to receive the separate chunks and rebuild the original file.

With these ideas in mind, now it is time to start the work, beginning from a simple control, to catch the file to upload, going down to the lower parts of the logic, until arriving to the server script.

Make things natural with Drag & Drop

Silverlight 4.0 introduced a new set of useful features, and one of them is the capability of dragging files from the client filesystem to the plug-in surface, letting the developer to detect the drop of these files and accessing an object to get information about the file and a Stream to read its content. The result is pretty similar to the selection of multiple files using the OpenFileDialog control, but from the point of view of the user the result is more natural.

The control, that I'm about to explain is a simple area that contains a ListBox. When someone drop some files onto the area, they are added to the ListBox and a ProgressBar control is displayed side by side with the file name. For this purpose I've created a templated-control. All the work starts when the AllowDrop property is set to true on the control. The code handles three events, to change the state of the control to Normal or Hover and to detect when the user finally drop the file. The state is used to give a feedback to the user about the dragging of files.

 this.AllowDrop = true;
 this.DragOver += (s, e) => VisualStateManager.GoToState(this, "Hover", true);
 this.DragLeave += (s, e) => VisualStateManager.GoToState(this, "Normal", true);
 this.Drop += new DragEventHandler(RootElement_Drop);

The dropped files are wrapped by an UploadFile class and added to an internal component we will discuss in the next paragraph. The ListBox is binded to the a collection of the files so it can display the elements and properties exposed by the UploadFile class. One of them is the Percentage of the upload that will be changed according with the progress. To add the files the code scans the FileInfo collection returned by the GetData method:

 private void RootElement_Drop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent("FileDrop"))
     {
         VisualStateManager.GoToState(this, "Normal", false);
  
         FileInfo[] files = (FileInfo[])e.Data.GetData("FileDrop");
  
         foreach (UploadFile file in from f in files
                                     where f.Exists
                                     select new UploadFile(f, this.ChunkSize))
             this.UploadManager.Add(file);
     }
 }

The control itself is really straightforward, with no surprises. All the needed logic infact, is implemented by an internal component called UploadManager. Having all the logic incapsulated in this component grants the developer the capability of use it without the need of using my Drag-and-Drop control. So if you need to use a traditional OpenFileDialog it is possible for sure.

The UploadManager

As you may have understand, the big part of the work is done by the UploadManager. The principle of it work is simple: It manages a queue of files to upload. When something is added to the queue it takes the files two by two, breaks them in chunks, and sends the chunks to the server. Every time a file has been completely uploaded it moves to another file and so on, until the end.

When I created this component I wanted to avoid to have a thread monitoring the internal queue of files. Probably this would be the simplest way to implement the component, but I think if I start a thread for every instance of the component it may easily become greedy of system resources. So I tried to take advantage of the threads started by the runtime to make asynchronous calls to the server and every time a completion callback is called, I test if other files are waiting to be uploaded. So when an item is added to the collection it starts a chain of upload and callbacks that end only when the queue is again empty. S,o in the Add method, I call the ProcessQueue method for the purpose of starting this process if it is idle:

 public void Add(UploadFile file)
 {
     if (!this.Files.Contains(file))
     {
         file.Reset();
         this.Files.Add(file);
         this.ProcessQueue();
     }
 }

Then in the ProcessQueue method the two files are selected from the queue using a LINQ query. The query exclude the completed files, and the ones that are still uploading. Then for each file selected the UploadChunk method starts the chunked send process:

 private void ProcessQueue()
 {
     if (this.UploadingFiles.Count < 2)
     {
         foreach (UploadFile file in (from f in this.Files
                                      where f.Percentage < 100.0 & !this.UploadingFiles.Contains(f)
                                      select f).Take(2 - this.UploadingFiles.Count))
         {
             this.UploadingFiles.Add(file);
             this.UploadChunk(file);
         }
     }
 }

Finally the UploadChunk method reads a block from an UploadFile instance and uses the HttpWebRequest  to call the server. The UploadFile class is responsible of tracking the progress of the upload. The callback calls again the UploadChunk method to continue the chain of operations:

 private void UploadChunk(UploadFile file)
 {
     byte[] chunk = file.ReadChunk();
  
     if (chunk == null)
     {
         this.UploadingFiles.Remove(file);
         this.ProcessQueue();
     }
     else
     {
         HttpWebRequest rq = (HttpWebRequest)WebRequestCreator.ClientHttp.Create(this.UploadHandlerUri);
  
         rq.Method = "PUT";
         rq.BeginGetRequestStream(
             result => this.DoPutUpload(result, file, chunk), rq);
     }
 }

The sole showstopper to this chain is the appearing of an Exception, perhaps caused by a network problem or something similar. I've accurately trapped the exceptions and I put the related file in a Fail state to avoid it from breaking the process. The UploadFile class has many properties, someone can use to display the current state of the file, the upload progress, the presence of an error, the current index of the chunk that is uploading.

Going to Server side

When I started to write the server side part of the UploadManager, I wanted to find the simplest way to make this operation without some sort of infrastructure. Since Silverlight is a cross platform technology, I decided to avoid the use of WCF, Ria Services or every other windows specific technology. My choice goes to the use of the PUT method, that is probably one of the primitive kind of file-uploading strategy.

Starting from Silverlight 3.0 the new Client networking stack supports some other methods like PUT, and DELETE and not only the usual GET and POST. With the PUT method a developer is able to access the raw input stream, and in the case of an ASP.NET server it is required to write only few row of code for a generic HTTP handler (ashx). But this implementation is simple also with different technologies like Java, PHP and other.

The sole trouble is that the UploadManager needs to send some other information, that the server side handler require to reconstruct the chunks into the original file. But the solution to this problem is also simple. I’ve made use of some custom Http Headers, where I put some vital information like filename, chunk index and chunk max. From the client side the code is the following:

 private void DoPutUpload(IAsyncResult result, UploadFile file, byte[] chunk)
 {
     HttpWebRequest rq = (HttpWebRequest)result.AsyncState;
  
     using (Stream stream = rq.EndGetRequestStream(result))
         stream.Write(chunk, 0, chunk.Length);
  
     rq.Headers["File-Name"] = file.File.Name;
     rq.Headers["Chunk-Index"] = file.ChunckIndex.ToString();
     rq.Headers["Chunk-Max"] = file.ChunkMax.ToString();
   
     rq.BeginGetResponse(
         r =>
         {
             try
             {
                 WebResponse rs = rq.EndGetResponse(r);
                 rs.Close();
  
                 Deployment.Current.Dispatcher.BeginInvoke(
                     () => this.UploadChunk(file));
             }
             catch (WebException ex)
             {
                 Deployment.Current.Dispatcher.BeginInvoke(
                     () => file.Fail(ex));
             }
         }, rq);
 } 

As you see after opening the request stream of an HttpWebRequest, I write the entire chunk bytes into it. Then using the Headers collection I create the File-Name, Chunk-Index and Chunk-Max headers. On the server side the filename will be used to match every chunk with previous received chunks. The index and the max instead are used to determine if the file is new (index == 1) or if the file has been fully received (index == max).

Finally, here is the server side code. It is all included in the ProcessRequest method of an HttpHandler, where I read the headers and start accumulating the incoming chunks. When the first chunk arrive I create a temporary file using Path.GetTempFileName(). This file name is retained in a Cache variable, called with the name of the file I’m receiving.

 public void ProcessRequest(HttpContext context)
 {
     string filename = context.Request.Headers["File-Name"];
     if (string.IsNullOrEmpty(filename)) throw new InvalidOperationException();
     
     int chunkIndex = int.Parse(context.Request.Headers["Chunk-Index"] ?? "-1");
     if (chunkIndex == -1) throw new InvalidOperationException();
    
     int chunkMax = int.Parse(context.Request.Headers["Chunk-Max"] ?? "-1");
     if (chunkMax == -1) throw new InvalidOperationException();
   
     using (Stream stream = this.GetStream(context, filename, chunkIndex))
     {
         byte [] data = new byte[context.Request.ContentLength];
         context.Request.InputStream.Read(data, 0, data.Length);
         stream.Write(data, 0, data.Length);
     }
   
     if (chunkIndex == chunkMax)
     {
         string destination = Path.Combine(context.Server.MapPath("~/Upload"), filename);
  
         if (File.Exists(destination)) File.Delete(destination);
         File.Move((string)context.Cache[filename], destination);
   
         context.Cache.Remove(filename);
     }
   
     context.Response.End();
 }

When the last chunk arrives, I write it to the temporary file, then I use the File.Move() method to move the file itself to the final destination on the server. In my case it is a folder in the project, but you probably will use a configuration key to determine your location. What I would recommend is not to pass the destination folder as a parameter on the query string or in the headers. This will be a great vulnerability in the security that leave an hacker free of saving everything on your server hard disk.

What may we improve?

The sample I provided attached to this article is far to be perfect. I already said about the path where to save the files, but there is a couple of thing that really need to be improved. The first is the problem that you have when someone stop the upload process in the middle of a transfer. In this case the server is not aware of the missing parts, so the temporary folder may grow over the capacity of your hard disk. This may open the way to DoS attacks. In my sample I've used the Cache removed callback that notify me when the element is not updated after a minute. In this case I delete the temporary file.

Another problem comes from the integrity of the file. In a real world solution you will have to use an hashing algoritm to verify that the sent file is equal to the received one. I hope my sample will be a good starting point.


Subscribe

Comments

  • nicholaspei

    RE: Uploading multiple files with Silverlight 4.0


    posted by nicholaspei on Jul 02, 2010 19:11
    It's really a creative file upload method, amazing ...... I love it. Thanks.
  • -_-

    Securit Error


    posted by Donald on Jul 03, 2010 02:29

    I get the following error:

    System.Security.SecurityException was unhandled by user code
      Message=""
      StackTrace:
           at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
           at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
           at SilverlightPlayground.Controls.UploadManager.<>c__DisplayClass9.<DoPutUpload>b__6(IAsyncResult r)
           at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassd.<InvokeGetResponseCallback>b__b(Object state2)
           at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
           at System.Threading.ThreadPoolWorkQueue.Dispatch()
           at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
      InnerException: System.Security.SecurityException
           Message=Security error.
           StackTrace:
                at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
                at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
                at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
           InnerException:

  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by Andrea Boschin on Jul 03, 2010 03:08

    Please check you have set the right uri in the MainPage.xaml markup code.

    let me know if this solve your issue. Thanks

  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by Donald on Jul 05, 2010 16:10
    That worked thanks.  I think I may have changed it because of a conflict.
  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by Dustin Horne on Jul 07, 2010 18:16

    The author missed one important thing.  Between the RC and the RTM I had the pleasure of having an email exchange with part of the Silverlight development team.  One of my biggest complaints was that even using the Silverlight networking stack instead of the browser, there was no good way to track upload progress (as noted above).  The key important feature that was missing was the ability to disable write stream buffering for the uploads and I thought this was key for Silverlight to be competitve for line of business apps.

    Between the RC and the RTM, the dev team implemented the feature.  If you use the HttpWebRequest object and Silverlight's networking stack you can set AllowWriteStreamBuffering to false and there is no longer a need to "chunk" the file prior to uploading to the server.  To demonstrate this, I created a Silverlight class library that uploads files directly to Amazon's S3 service without the need for a proxy server.  The library constructs a form POST and uploads the file and related data.

    The same can be used for any HttpWebRequest call.  Even if you're uploading to a page on your own server that process the file, you can disable write stream buffering and accurately track the progress of the upload.  My test class fires an event whenever a packet is sent to the stream, but a better method would be to implement IObservable on a readonly property that exposes the number of bytes uploaded (and have another property that exposes the total number of bytes for the current request).  By simply updating the bytes sent property when each set of bytes (buffer) in your loop is pushed to the server, anything bound to that property (such as the text of a label or position of a progress bar with some calculation) could accurately display the progress, making it a far more simple task since the file won't have to be manually reconstructed on the server side across multiple requests, but rather just pulled from the stream in one go.

  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by Dustin Horne on Jul 08, 2010 23:03
    Just wanted to make a correction to my post from yesterday...I stated IObservable for the property, but I meant "INotifyPropertyChanged".
  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by hyspdrt on Jul 09, 2010 13:32
    Regarding AllowWriteStreamBuffering, there are a couple of gotchas with that as documented here (http://support.microsoft.com/kb/908573). Also, if you don't do chunking how do you handle canceling the request mid-stream, clean up on the server and time outs on large files? I have created a full control suite that handles all of this and is free on codeplex (interlink.codeplex.com) but uses chunking. It's fairly robust and support extra feature such as hashing/validation, cancel, retry and file overwriting. It's fairly simply to integrate and use.
  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by Toni on Jul 16, 2010 22:10

    Failed to assign to property 'System.Windows.UIElement.AllowDrop'. [Line: 8 Position: 60]

    That's the error I get. No one else got it? Can anyone help? Pretty please? :)

  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by Andrea Boschin on Jul 17, 2010 00:56
    that's strange, Have you run VS2010 with Administrator priviledges? If it is so please run it normally.
  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by Angelo on Jul 18, 2010 18:14

    When i deploy this online it doesn't seem to work. the only setting i heva changed is the UploadHandlerUri in the mainpage. Then i uploaded everything. When testing on my local pc it gives the security error. Does somebody have a clue ?

    {System.Security.SecurityException ---> System.Security.SecurityException: Security error.
       bij System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
       bij System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
       bij System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
       --- Einde van intern uitzonderingsstackpad ---
       bij System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
       bij System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
       bij SilverlightPlayground.Controls.UploadManager.<>c__DisplayClass9.<DoPutUpload>b__6(IAsyncResult r)
       bij System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassd.<InvokeGetResponseCallback>b__b(Object state2)
       bij System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
       bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       bij System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
       bij System.Threading.ThreadPoolWorkQueue.Dispatch()
       bij System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()}

  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by Dustin Horne on Jul 20, 2010 19:30

    hyspdrt -

    That only applies in somescenarios, in many cases it will work just fine.  To illustrate my example, I have an upload component that uploads directly to Amazon's S3 service.  The upload is still 'chunked' in that it writes set buffers to the response stream, however it does so with a single connection which removes the overhead of making connection after connection after connection.  My example doesn't automatically cancel if your credentials are incorrect, but I do have the facilities to cancel the upload and it was very simple to implement, just by checking for a cancellation request before each buffer is written. 

    Ignore the "Load From Stream" button in my example, but you can load a file and upload.  This will work as long as you have a properly constructed and public readable clientaccesspolicy.xml file in your Amazon bucket that allows at a minimum the domain my example is served from:

    http://www.parentelement.com/sls3test.html

  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by hyspdrt on Aug 09, 2010 14:35

    Thanks for the follow up. I think our solutions are very comparable in how they creatively deal with threading on the client, but I wanted to support more abstraction between the infrastructure (the guts of the tool) and what the end developer needs to implement. Including a clear distinction of cancelling an upload and positive confirmation back to the client app, in addition to providing retry and hashing capability to an indivdual chunk. So I've segmented out the communication protocol and then allow the developer to implement a base class so they can simply provide there storage logic (database, file, etc.). I like your solution as well, and serves the purpose. And is probably more flexible for those that want to change the code directly. HSS Interlink is more of a component library, with the only coding requirement is to implenent one or more File Handler(s).

    Example, this is all that is required by the developer to implement their upload storage logic...

    public override bool CheckFileExists()
    public override Responses CreateNewFile()
    public override Responses AppendToFile(byte[] buffer) // called for each chunk
    public override void CancelUpload()
    public override void UploadComplete()
    public override bool IsAuthorized() // called for each request

    UploadComplete provides the opportunity to delete any temp files you may create, and IsAuthorized allows for validation of each request. With this protocol it does make connection after connection, but it provides for more server side throughput, in that each chunk from 100's of users could run concurrently versus locking a single server side request connection/process for a period of time for a single file.

    Look here for a demo of HSS Interlink @ http://hssinterlink.com/

    For more details see http://interlink.codeplex.com/

  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by hyspdrt on Aug 09, 2010 14:52

    Actually, after reviewing your source code, it appears you do make a connection for each chunk...

    From your UploadChunk(UploadFile file) method:

     

    HttpWebRequest rq = (HttpWebRequest)WebRequestCreator.ClientHttp.Create(this.UploadHandlerUri);

    Why is you believe it's a single connection? 

     

     

  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by Dustin Horne on Aug 10, 2010 18:53

    hyspdrt -

    Are you talking to me?  You're looking at the author of this article's source code, not mine.  :P  Run my sample application and look at the traffic via Wireshark.  It's a single connection that streams the data and offers notification via an event model and property change notification to give you upload status.  It also allows cancellation of the upload.

  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by Dustin Horne on Aug 10, 2010 18:55
    I also want to add that my library uploads directly to Amazon S3, not using a file handler so it doesn't lock any process at the host server level.    
  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by doctorgu on Aug 26, 2010 14:22

    very cool code.

    Your code is very optimized, a lot of new technology.

    I changed your source a little as below because of Korean character.

    In Silverlight: rq.Headers["File-Name"] = HttpUtility.UrlEncode(file.File.Name);

    In ASP.Net: string filename = HttpUtility.UrlDecode(context.Request.Headers["File-Name"]);

    Thanks a lot!

  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by Andrea Boschin on Aug 26, 2010 14:45
    thanks, good catch!
  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by NMH on Sep 03, 2010 13:39
    Just blogged about this, its a really cool control.

    http://blogs.3sixtysystems.com/NMH/post/Discovered-a-really-cool-multiple-file-uploader.aspx
  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by Pablo Lima on Oct 01, 2010 00:35

    Did any one had some problem with this solution running on IIS 7.5 ?

  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by Kamil on Nov 17, 2010 04:36

    Hi everyone,

    I'm  new in silverlight and i need a fileupload project to improve myself ,but the above example is really hard to understand , can anyone help me? 

  • -_-

    RE: Uploading multiple files with Silverlight 4.0


    posted by Andrea Boschin on Nov 18, 2010 09:57
    hi Kamil, what kind of help do you need?
  • -_-

    RE: Uploading multiple files with Silverlight


    posted by CK on Mar 18, 2011 05:40

    Thank Andrea Boschin very much.

    I believe this will help a lot of people.

    But i face a problem here and hope you able to help me.

    I am new in silverlight.

    Eveything work OK when i run from solution SilverlightPlayground.MultiFileUpload.sln.

    After I copy the whole folder SilverlightPlayground.MultiFileUpload to C:\ with 3 Sub folder inside.

    1. SilverlightPlayground.Controls
    2. SilverlightPlayground.MultiFileUpload.Silverlight
    3. SilverlightPlayground.MultiFileUpload.Web

    From IIS, i create a virtual directory point to the folder C:\SilverlightPlayground.MultiFileUpload with Alias name MultipleUpload.

    here i attach the print screen of my local IIS so that you are more clearer on this. http://www.flickr.com/photos/47392278@N05/5535972357/

    The URL to run demo.html page is http://localhost/MULTIPLE/SilverlightPlayground.MultiFileUpload.Web/demo.html.

    should i change the UploadHandlerUri from the MainPage.xaml to....?

    1. http://localhost/MULTIPLE/SilverlightPlayground.MultiFileUpload.Web/upload.ashx
    2.  

       

       

      http://localhost/MULTIPLE/upload.ashx
      or or other correct Uri?

      I face the error message below:

      {System.Security.SecurityException ---> System.Security.SecurityException: Security error.
         bij System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
         bij System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
         bij System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
         --- Einde van intern uitzonderingsstackpad ---
         bij System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
         bij System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
         bij SilverlightPlayground.Controls.UploadManager.<>c__DisplayClass9.<DoPutUpload>b__6(IAsyncResult r)
         bij System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassd.<InvokeGetResponseCallback>b__b(Object state2)
         bij System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
         bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
         bij System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
         bij System.Threading.ThreadPoolWorkQueue.Dispatch()
         bij System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()}

    Please assit on me, thank you.

  • tayzirov

    Re: Uploading multiple files with Silverlight


    posted by tayzirov on Jul 13, 2011 01:45

    hi
    when I open up the solution and try to open up the xaml files, I immediately get the following errors:

    Warning 1 Could not load file or assembly 'file:///C:\Users\AWESOME-02\Downloads\SilverlightPlayground.MultiFileUpload\SilverlightPlayground.Controls\Bin\Debug\SilverlightPlayground.Controls.dll' or one of its dependencies. The system cannot find the file specified. SilverlightPlayground.MultiFileUpload.Silverlight

    Error 2 Unable to load the metadata for assembly 'SilverlightPlayground.Controls'. This assembly may have been downloaded from the web.  See http://go.microsoft.com/fwlink/?LinkId=179545.  The following error was encountered during load: Could not load file or assembly 'SilverlightPlayground.Controls, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. C:\Users\AWESOME-02\Downloads\SilverlightPlayground.MultiFileUpload\SilverlightPlayground.MultiFileUpload.Silverlight\MainPage.xaml 1 1 SilverlightPlayground.MultiFileUpload.Silverlight

    Error 3 The type 'slpgcontrols:MultipleFileUpload' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. C:\Users\AWESOME-02\Downloads\SilverlightPlayground.MultiFileUpload\SilverlightPlayground.MultiFileUpload.Silverlight\MainPage.xaml 9 10 SilverlightPlayground.MultiFileUpload.Silverlight


    Is Silverlight Playground some kind of toolkit? I've never heard of it before.
  • tayzirov

    Re: Uploading multiple files with Silverlight


    posted by tayzirov on Jul 15, 2011 09:08

    Oh no I get it, they're custom controls. False Alarm.

  • FelipeEsteves

    Re: Uploading multiple files with Silverlight


    posted by FelipeEsteves on Mar 12, 2012 16:25

    Thank you a lot Andrea Boschin. Great arcticle.


     

    I´m using IIS 7.5 and I´ve found the same problem of CK.

    I had to enable the upload handler to work on IIS7.5 . I enabled the "PUT" action on IIS Handlers

    The folowing code inside the web.config worked to me : 

    <system.webServer>

    <validation validateIntegratedModeConfiguration="false" />
    <directoryBrowse enabled="true" />
    <handlers>
    <remove name="SimpleHandlerFactory-Integrated-4.0" />
    <add name="SimpleHandlerFactory-Integrated-4.0" path="*.ashx" verb="GET,HEAD,POST,DEBUG,PUT" type="System.Web.UI.SimpleHandlerFactory" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    </system.webServer>


  • AmbasthaRajiv

    Re: Uploading multiple files with Silverlight


    posted by AmbasthaRajiv on May 02, 2012 22:37
    In silverlight, for uploading file this link is really good :)
    http://interview-development.blogspot.in/2012/05/silverlight-upload-file.html
  • jgakenhe

    Re: Uploading multiple files with Silverlight


    posted by jgakenhe on May 20, 2012 20:53
    I give up after 2 hours. I get a blank screen and sick of playing with it.

Add Comment

Login to comment:
  *      *