Get values of evidence eid and hash in user settings path construction

旧街凉风 提交于 2019-12-21 17:07:07

问题


By default user settings of win application 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 values of eid and hash.

I'm trying to get that information from the AppDomain.CurrentDomain.Evidence and then check values I'm getting from GetHostEnumerator() but they aren't fit the actual directory path values.

For Example I have the following values

Some.exe_StrongName_fymjkuum4xrf5aopfjlsem3elhvjbgag

But the information I recieved from code is

<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 signing. May be it's the value from my key ?


回答1:


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

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


来源:https://stackoverflow.com/questions/11339704/get-values-of-evidence-eid-and-hash-in-user-settings-path-construction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!