简体   繁体   English

如何在Visual Studio中本地调试文件权限问题?

[英]How can I locally debug file permission issues in Visual Studio?

I want to debug an ASP.Net website as it attempts to write a file to a directory. 我想调试ASP.Net网站,因为它试图将文件写入目录。

When actually deployed this file would possibly not be writeable by the worker process so an error would be thrown, this is not a problem as I just want to catch the error, inform the user and move on. 实际部署时,该文件可能无法由工作进程写入,因此会引发错误,这不是问题,因为我只是想抓住错误,通知用户并继续前进。

Of course, if I'm debugging on my local machine then I'm an administrator and I have permission to write to the file, so I can't check that I've trapped the correct errors and I can't step through an see where it goes wrong if I haven't. 当然,如果要在本地计算机上调试,则我是管理员,并且有权写入该文件,因此无法检查是否已捕获正确的错误,也无法逐步执行如果没有的话,看看哪里出了问题。 Is there a standard approach to this sort of thing? 是否有处理这种事情的标准方法?

You could replace the file writing methods with mock methods that you can modify to return the desired values (or raise the appropriate exception). 您可以用模拟方法代替文件写入方法,您可以修改这些模拟方法以返回所需的值(或引发适当的异常)。

Look into mocking frameworks. 查看模拟框架。

Another solution could be to temporarily remove your write permissions from those folders. 另一种解决方案是从这些文件夹中临时删除您的写权限。 You still have full control so you can put the rights back after you've finished testing. 您仍然拥有完全控制权,因此可以在完成测试后放回权利。

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

相关问题 如何在Visual Studio中更快地调试? - How can I debug faster in Visual Studio? Visual Studio 2005说我没有调试权限? - Visual Studio 2005 says I don't have permission to debug? 如何确定ASP.NET网站是通过Visual Studio“正常”运行还是在“调试”状态运行? - How can I identify whether an ASP.NET site is being run “normally” or in “debug” via Visual Studio? 如何在Visual Studio 2010中更快地调试ASP.NET应用程序 - How can I debug asp.net applications more quickly in Visual Studio 2010 在ASP.NET中运行主项目时(使用Visual Studio(2010))如何调试工作目录* .aspx.cs文件? - How can I debug a working directory *.aspx.cs file when running the main project in ASP.NET (using Visual Studio (2010))? 如何使用Visual Studio在ASP.NET中调试JavaScript文件 - How to debug javascript file in ASP.NET with Visual Studio 无法在具有 Docker 支持和 Visual Studio 提供的 SQL Server 的 Visual Studio 中进行本地调试 - Cannot debug locally in Visual Studio with Docker support and Visual Studio provided SQL Server Visual Studio 2010和2012 ASP.Net调试和布局问题 - Visual Studio 2010 & 2012 ASP.Net debug & layout issues Visual Studio在调试时拉错CSS文件 - Visual Studio is Pulling Wrong CSS File on Debug 在Visual Studio 2010中调试Javascript文件? - Debug Javascript file in Visual Studio 2010?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM