Get eid and hash evidence values ​​in building user settings path

By default, win application user settings are stored in the following directory

Vista / 7

C:\Users\<userId>\AppData\Local\Application Data\<companyname>\appdomainname>_<eid>_<hash>\<verison>

XP

C:\Documents and Settings>\<username>\[Local Settings\]Application Data\<companyname>\appdomainname>_<eid>_<hash>\<verison>

I need to know how to get the eid and hash values.

I try to get this information from AppDomain.CurrentDomain.Evidence and then check the values ​​that I get from GetHostEnumerator (), but they do not match the actual values ​​of the directory path.

For example, I have the following meanings

 Some.exe_StrongName_fymjkuum4xrf5aopfjlsem3elhvjbgag 

But the information obtained from the code,

 <StrongName version="1" Key="002400000480000094000000060200000024000052534131000400000100010027BFE9320943DDB4271C78B6B890E7BF02ECAA65585E252D8FBF07888FAAC54D8F8EF25C65061D4F8B904699701BF437F5A69BBDB6A496B989F8FD96853E43C621A84C187AF9EA90C0DAF7F32134A3BD42E94023DBB601C864CA1FF0B5E520CD090A4B90EDB1F95628F750316DBCC9593603E033D72FD67F2707D2670A2D1EB2" Name="Some" Version="0.0.0.0"/> <System.Security.Policy.Url version="1"> <Url>file:///R:/Some/Some.Utilities/bin/Debug/Some.EXE</Url> </System.Security.Policy.Url> <System.Security.Policy.Zone version="1"> <Zone>MyComputer</Zone> </System.Security.Policy.Zone> <System.Security.Policy.Hash version="2"> <hash algorithm="SHA1" value="8B19FB026023FE0C239D96EECDDC0266D36B415B"/> <hash algorithm="SHA256" value="46AA666701E20EF698ABE20F60CD52162BD0D7B72B43D1B1EB82826E525ACE73"/> <hash algorithm="MD5" value="244B4EA2E084F98345FE56FB4460A436"/> </System.Security.Policy.Hash> 

By the way, my assembly is being signed. Maybe this value is from my key?

+4
source share
1 answer

You can get the location where the settings file will be saved by default for your application using the following line of code. From this you can extract eid and hash.

 string configPath = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath; 
+3
source

All Articles