在Visual Studio调试期间从哪里加载user.config [英] Where is user.config loaded from during Visual Studio debugging

查看:122
本文介绍了在Visual Studio调试期间从哪里加载user.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从用户设置文件读取的应用程序,该文件通常存储在Users/{username}/AppData/Local/{publisher}/{app}/{version}/user.config中.我要测试直接对文件进行更改,而不是通过Visual Studio属性编辑器进行测试.

I have an application that reads from a user settings file, typically stored in Users/{username}/AppData/Local/{publisher}/{app}/{version}/user.config. I want to test making changes directly to the file, not through the Visual Studio properties editor.

我找到了这个答案,它指向另一个不同的问题,该问题指向应用程序应该从何处加载文件,但是在Visual Studio的调试会话中进行检查时,似乎不存在.

I found this answer to a different question that points to where the application is supposedly loading the file from, but it doesn't seem to exist when I check during a debug session in Visual Studio.

例如,当我在断点处停止时在即时"窗口中运行以下命令时,它找不到文件.

For example, when I run the following in the Immediate window when stopped on a breakpoint, it fails to find the file.

System.IO.File.Exists(System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath) //returns false

我想在调试期间找到此文件的原因是,我收到了有关配置文件已损坏并使生产中的应用程序崩溃的报告.我确定我可以将文件恢复为默认状态,但实际上我想在调试环境中重现该问题.

My reason for wanting to find this file during debugging is that I have received reports of the config file being corrupted and crashing the application in production. I'm sure that I can return that file to a default state, but I want to actually reproduce the problem in a debug environment.

如何找到Visual Studio加载的设置文件?

How can I find the settings file loaded by Visual Studio?

推荐答案

我不太确定在发布此问题与现在之间有什么变化,但是今天问题中的代码返回true.但是要回答我问的具体问题,user.config文件与标准安装的应用程序的路径非常相似.

I'm not quite sure what changed between when I posted this question and now, but today the code in my question returns true. But to answer the specific question I asked, the user.config file was in a very similar path to a standard installed application.

标准应用程序:

用户/{用户名}/AppData/本地/{发布者}/{app}/{版本}/user.config

Users/{username}/AppData/Local/{publisher}/{app}/{version}/user.config

Visual Studio调试应用程序:

Visual Studio debug application:

Users/{用户名}/AppData/Local/{publisher}/{app} .vshost.exe {some_hash_value}/{version}/user.config

Users/{username}/AppData/Local/{publisher}/{app}.vshost.exe{some_hash_value}/{version}/user.config

这篇关于在Visual Studio调试期间从哪里加载user.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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