I'm getting a sharing violation exception when using RadAsyncUpload (version 2010.3.1117.35) to upload an Excel file which is also open in another window.
Is there a way to trap or prevent the error? The exception appears to occur before the client-side events fire, so neither the
OnClientFileUploadFailed or OnClientValidationFailed execute.
Thanks in advance for your help,
20 Answers, 1 is accepted
I tried uploading a file open in Excel without any issues.
What do you mean by open in another window? Can you provide me with a step-by-step use-case, which I can test on my side to reproduce the exception?
Best wishes,
Simon
the Telerik team
Hi Simon,
1. Open a spreadsheet in Excel. (I'm using Excel 2007)
2. Use the AsyncUpload control to attempt to upload the file while it is still open in Excel.
3. An error occurs and the file isn't loaded into the RadUploadTemp folder.
That's what I mean by "open in another window". One window is Excel and the other is the browser.
I'm able to upload to file without problem if I close the file in Excel. The following two errors are recorded in the FF error console, although the problem exists in IE as well.
Let me know if you need more info.
Thanks,
Error: uncaught exception: Error while uploading, [IO.IO_SharingViolation_File]
Arguments: 2007 format.xlsx
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.50917.0&File=mscorlib.dll&Key=IO.IO_SharingViolation_File
Error: Unhandled Error in Silverlight Application [IO.IO_SharingViolation_File]
Arguments: 2007 format.xlsx
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.50917.0&File=mscorlib.dll&Key=IO.IO_SharingViolation_File ; at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
at System.IO.FileInfo.OpenRead()
at UploadPrototype.UploadContext.GetCurrentChunk()
at UploadPrototype.MainPage.ProcessRequest(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass9.<
InvokeGetRequestStreamCallback
>b__7(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()
Line: 0
Thank you for the additional info.
It seems that Excel 2007 locks the file for reading when after opening it. I first tested in Excel 2010, which did not lock the file, so I could not see the error.
I logged this issue and updated your Telerik points for finding it and reporting it to us. We will address the bug in the upcoming weeks.
All the best,
Simon
the Telerik team
The issue is still in the log for fixing. Since RadAsyncUpload is currently undergoing a series of other more important fixes this one would be probably be addressed at a later time.
Regards,
Simon
the Telerik team
Has this issue been fixed? Is it fixed for any file that you might try to upload that is open (i.e. Excel 2010, 2007, 2003)? Which version was this addressed in, if so- I may have to upgrade to it. Finally, is there a way to trap this situation in an error, and report a friendly message to the user?
Thanks,
Steve
After further investigation, it seems that Silverlight cannot access files that are opened by another process. With the latest version of our controls- Q2 2011 it is possible to upload already opened files with all other modules: IFrame/Flash/FileApi.
Please use the javascript code below to disable the Silverlight module:
Telerik.Web.UI.RadAsyncUpload.Modules.Silverlight.isAvailable =
function
() {
return
false
; };
Regarding Steve's last post on 04-Aug-2011. Please use OnClinetFileUploadFailed event.
Regards,
Peter Filipov
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.
I'm not sure what each of the suggestions that you made does:
Does the silverlight script diable Silverlight? or the functioning of the AsynchUpload control's use of Silverlight? If you do this, does that diable filters for the file types (I am only allowing .xlsx or .xls in my application- and I do not wish to give that up)? What do the other API's do compared to Silverlight?
OnClientFileUploadFailed- the link does not provide any details regarding what that does, or how it is implemented. Currently, I am providing a warning on the page if the UploadedFiles collection.Count()=0. This can be true both if the file could not be uploaded for any reason, such as having the file opened, or because the user has yet to select a file to upload. My hope was to distinguish between the two scenarios.
I am using QTR 2 2011, so the latest version still has the issue. Will it be addressed, or is this the best we are going to get?
Thanks
Using the sample code in my last post disable the functioning of the RadAsynchUpload to use Silverlight. Silverlight will be available for all other applications.
Here is a list of the modules used in different browsers by priority:
Firefox - Silverlight-FileApi-Flash
IE - Silverlight-Flash-IFrame
With FIleApi and IFrame module it is not possible to use the dialog filter. Nevertheless the validation if the correct file type is selected is working fine.
Regarding OnClientFileUploadedFail event handling, please consult with the following sample code:
<
script
type
=
"text/javascript"
>
function FileUploadFailed(sender, args) {
alert(agrs.get_message());
}
</
script
>
<
telerik:RadAsyncUpload
runat
=
"server"
ID
=
"AsyncUpload1"
OnClientFileUploadFailed
=
"FileUploadFailed"
>
</
telerik:RadAsyncUpload
>
I hope this information helps. I will be glad to assist you further.
Kind regards,
Peter Filipov
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.
Telerik.Web.UI.RadAsyncUpload.Modules.Silverlight.isAvailable =
function() { return false; };
I get an javascript error "Exception thrown and not caught" when trying to upload a file opened on the client machine.
How do I get rid of this error and still be able to upload the file.
Thanks,
Raji
I have tried to reproduce the same behavior but to no avail. I am attaching my test project. Please review it and let me know if you still can observe the same behavior at your side with it.
If yes please try to set the DisablePlugins property to True and let us know what was the result as well.
Plamen
the Telerik team
I tried to execute your same app and when I try to browse a file and upload I get the login prompt. If I set the value to true, the propt goes away. I am using .Net 2.0 framework and VS2005.
Telerik.Web.UI.RadAsyncUpload.Modules.Silverlight.isAvailable =
function () { return true; }I would like the user to upload a file that is opened on users machine. With the above value set to true. I get the javascript error "Exception thrown and not caught".
Thanks,
Raji
Have you tried to remove the javascript you posted above and set the DisablePlugins="True" property of RadAsyncUpload?
Plamen
the Telerik team
I utilized the OnClientFileUploadFailed event. It will display to the user that the file is in use and remove the selected file from RadAsyncUpload and allows the user to select the file again without having to remove it first.
function OnClientFileUploadFailed(sender, args) {
var label = document.getElementById('<%=lblresult2.ClientID %>')
var upload = $find("<%= rdupload2.ClientID %>");
var errormsg = args.get_message();
var displaymsg = new String();
sender.deleteFileInputAt(0);
if (errormsg.search("[IO.IO_SharingViolation_File]") != -1) {
displaymsg = errormsg.substr(42, 10) + " is currently in use. Please close the file and try again.";
}
else {
displaymsg = "The file you selected is currently in use. Please close the file and try again.";
}
alert(displaymsg);
args.set_handled(true);
}
<
telerik:RadAsyncUpload
ID
=
"rdupload2"
runat
=
"server"
UploadedFilesRendering
=
"BelowFileInput"
OnClientFilesUploaded
=
"filesuploaded2"
Width
=
"260px"
AllowedFileExtensions
=
".xls,.xlsx,.txt,.raw"
TemporaryFileExpiration
=
"00:01:00"
TemporaryFolder
=
"~/tempdocs"
MaxFileInputsCount
=
"1"
OnClientFileUploadRemoved
=
"filesremoved2"
Font-Size
=
"Medium"
Skin
=
"Office2010Blue"
OnClientFileSelected
=
"OnClientFileSelected"
OnClientFileUploadFailed
=
"OnClientFileUploadFailed"
>
</
telerik:RadAsyncUpload
>
* The errormsg.substr gets the selected filename to display in the alert if the error is a IO.IO_SharingViolation_File.
Hope this is useful to someone.
Thank you for sharing your solution with the community.
Plamen
the Telerik team
When we will have a fix on the component level about this issue?.
I can't use disable plugins because I will disable the rich features of the component and we are using IE9 and IE10 with the silverlight backend.
Mr.Jeff comment shows a work around but I think we need something more robust.
I will really appreciate if you can give an estimation about this issue that have long time affected the RadAsyncUpload component.
Best Regards,
Skandar.
We have been inspecting the issue and it seems that the problem is rather a limitation of the Silverlight module itself than with RadAsyncUpload. The is why unfortunately at the moment we can not commit on ETA for fixing it.
Hope this will explain the issue.
Plamen
Telerik
Thank you for your support, I guess we will go with Mr.Jeff workaround is the only option and in the near future drop support for Silverlight.
Regards,
Skandar.
Thanks... Ed