简体   繁体   English

删除dll时出现System.UnauthorizedAccessException(C#)

[英]System.UnauthorizedAccessException while deleting dll (C#)

Please read carefully: I know that dlls can be in use. 请仔细阅读:我知道可以使用dll。 I also know about NTFS permissions, and read-only flag. 我也知道NTFS权限和只读标志。

  1. I create a text file with content hello. 我创建了一个带有内容问候的文本文件。
  2. I rename it to .dll 我将其重命名为.dll
  3. I try to use File.Delete(...) method to delete it: I got System.UnauthorizedAccessException 我尝试使用File.Delete(...)方法删除它:我得到了System.UnauthorizedAccessException
  4. I try to open it with File.OpenWrite(...) I got the same exception. 我尝试用File.OpenWrite(...)打开它,但出现了同样的异常。
  5. I've turned out all virus checking software. 我发现所有的病毒检查软件。
  6. I am admin in my Windows 7 machine. 我是Windows 7计算机的管理员。
  7. I am the owner of the .dll extension file 我是.dll扩展文件的所有者
  8. I can it delete without any warning from the UI. 我可以删除它而无需从UI中发出任何警告。

Using VS 2012 C# program (.NET 4.5) 使用VS 2012 C#程序(.NET 4.5)

Any ideas? 有任何想法吗? Thanks 谢谢


SOLVED: (partly): This was my firewall :-(. Somehow it cached and sandboxed my project output executable, and restricted to delete .dlls (not .txts). Although I turned off it, and I rebuild the .exe many times somehow the named exe sandboxed state remained active. I stress it was a many times rebuild and binary changed .exe. Congratulations to Commodo just 2 erratic behaviour in on issue. 1) Why the sandboxing is still active if antivirus has turned off? 求助:(部分):这是我的防火墙:-(。以某种方式将其缓存并沙箱化了我的项目输出可执行文件,并且限制为删除.dll(不是.txts)。尽管我将其关闭,但我还是多次重建.exe。不知何故,命名的exe沙盒状态仍然处于活动状态,我强调这是很多次重建和二进制更改的.exe。祝贺Commodo出现了2种不稳定的行为:1)如果关闭了防病毒功能,为什么沙盒仍然处于活动状态? 2) Why not reevaluate the named .exe file and asking me about sandboxing if the binary has changed? 2)为什么不重新评估命名的.exe文件并询问有关沙箱的问题,如果二进制文件已更改? How this is turned out? 结果如何? I renamed the project output to x.exe :-( 我将项目输出重命名为x.exe :-(

This was more the 45 minutes from my life and worktime... 距离我的工作和生活时间只有45分钟...

For delete try 对于删除尝试

File.SetAttributes(file, FileAttributes.Normal);
File.Delete(file);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 删除dll时出现System.UnauthorizedAccessException - System.UnauthorizedAccessException while deleting dll WinForms中的System.UnauthorizedAccessException C# - System.UnauthorizedAccessException C# in winforms 在LINQ中C#处理System.UnauthorizedAccessException - C# Handle System.UnauthorizedAccessException in LINQ 如何修复这个 System.UnauthorizedAccessException? C# - How to fix this System.UnauthorizedAccessException? C# 忽略文件夹C#(System.UnauthorizedAccessException) - Ignore folder C# (System.UnauthorizedAccessException) 尝试在C:\\驱动器中创建文件时,“ mscorlib.dll中发生''System.UnauthorizedAccessException' - “ 'System.UnauthorizedAccessException' occurred in mscorlib.dll” while trying to create file in the C:\ drive 使用错误System.UnauthorizedAccessException将图像保存在WPF C#中的mscorlib.dll中发生 - Saving Image in WPF C# with an error System.UnauthorizedAccessException occurred in mscorlib.dll C#mscorlib.dll中发生未处理的“System.UnauthorizedAccessException”类型异常 - C# An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll 文件中的 System.UnauthorizedAccessException。创建 c# - System.UnauthorizedAccessException in File.Create c# System.UnauthorizedAccessException:拒绝访问路径 (UWP C#) - System.UnauthorizedAccessException: Access to the path is denied (UWP C#)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM