[UWP]使用System.UnauthorizedAccessException保存文件偶尔会失败:访问被拒绝。 [英] [UWP]Saving a file occasionally fails with System.UnauthorizedAccessException: Access is denied.

查看:386
本文介绍了[UWP]使用System.UnauthorizedAccessException保存文件偶尔会失败:访问被拒绝。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在桌面上运行了一个基本的UWP应用程序。偶尔我收到来自用户的错误报告抱怨保存他们的文件失败并出现此错误:


System.UnauthorizedAccessException:访问被拒绝。 (Excep_FromHResult 0x80070005)

    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   在SharedLibrary!< BaseAddress> + 0x4511ee

   在SharedLibrary!< BaseAddress> + 0x451168

   在SharedLibrary!< BaseAddress> + 0x50c81a

    at System.Action.Invoke()

---从抛出异常的上一个位置开始的堆栈跟踪结束---

    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   在SharedLibrary!< BaseAddress> + 0x4511ee

   在SharedLibrary!< BaseAddress> + 0x451168

   在SharedLibrary!< BaseAddress> + 0x50c81a


有没有人遇到过类似的问题?这似乎是在随机时间发生的,即用户无法可靠地再现它。保存工作大部分时间,但不是所有时间,这是一个问题...


以下是我认为引发错误的行:


  &NBSP;  (StorageFile):tempZipFile.MoveAndReplaceAsync(this.zipFile).AsTask()。GetAwaiter()。GetResult();


Any想法我能检查什么?我计划通过添加的调试信息向我的应用发布更新。 


谢谢!


解决方案

如果它是间歇性的,那么它可能是一个时间问题或干扰其他一些应用程序或进程系统。您唯一能做的就是捕获错误并稍后再试。


应用程序应始终认为文件访问可能会失败并正常处理该失败状态。 / p>


I have a basic UWP app running on the desktop. Once in a while I receive error reports from users complaining that saving their files fails with this error:

System.UnauthorizedAccessException: Access is denied. (Excep_FromHResult 0x80070005)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at SharedLibrary!<BaseAddress>+0x4511ee
   at SharedLibrary!<BaseAddress>+0x451168
   at SharedLibrary!<BaseAddress>+0x50c81a
   at System.Action.Invoke()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at SharedLibrary!<BaseAddress>+0x4511ee
   at SharedLibrary!<BaseAddress>+0x451168
   at SharedLibrary!<BaseAddress>+0x50c81a

Did anybody ever run into a similar problem? This seems to happen at random times, i.e. users can't reliably reproduce it. Saving works most of the time, but not all the time, which is a problem...

Here is the line of which I think is throwing the error:

     (StorageFile): tempZipFile.MoveAndReplaceAsync(this.zipFile).AsTask().GetAwaiter().GetResult();

Any ideas what I could check for? I'm planning to release an update to my app with added debug information. 

Thanks!

解决方案

If it's intermittent then it's probably a timing issue or interference with some other app or process on the system. The only thing you'll be able to do about it is to catch the error and try again later.

Apps should always assume that file access can fail and handle that failure state gracefully.


这篇关于[UWP]使用System.UnauthorizedAccessException保存文件偶尔会失败:访问被拒绝。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆