开发者

C# settings. How is the path for appdata determined?

For the sake of this question, assume Vista or Win 7 OS. I am writing an app that is a console app bu开发者_运维技巧t with a form gui for the user to make settings. This program is called and used by another app.

Now, when I run debug, the config file is saved at C:\Users\gpearson\AppData\Local\LameCooter\ReFLAC.vshost.exe_Url_n0ekhuv0sj03zsscwvzaubkqj0rny1jg\1.0.1.0\user.config but when the outside app runs my programs, the config file is looked for at C:\Users\gpearson\AppData\Local\LameCooter\reflac.exe_Url_wkb5qtqxm1o4a0d42yibofh0l0x3wu3k\1.0.1.0\user.config the difference being :

path #1: ReFLAC.vshost.exe_Url_n0ekhuv0sj03zsscwvzaubkqj0rny1jg

path #2: reflac.exe_Url_wkb5qtqxm1o4a0d42yibofh0l0x3wu3k

Why the difference?

All the documentation I can find says the path will be ...\AppData\Local\Company Name/Program Name\Program version\user.config


This is because Visual Studio creates another .exe file which makes it easier to debug called a VSHOST file(example MyApp.vshost.exe). This becomes your exe when running in debug mode. While in normal/production/release code the only .exe you have is the normal one. This is why you're seeing that disparity.


The vshost.exe feature was introduced with VS2005 . It aims to make debugging launch very quicker .

So this is the reason why when you run Console.Write(System.AppDomain.CurrentDomain.FriendlyName) from the debugger, you get app.vshost.exe and when you run directly from the exe you will be getting output as app.exe

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜