0
レジストリからパラメータを読み込むアプリケーションを作成しています。C#LocalMachineでレジストリ値を読み込めません
public bool getRegValues() //get values used for the SQL Connection etc
{
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Company\Application\NightJob\", RegistryKeyPermissionCheck.ReadWriteSubTree))
{
if (key != null)
{
this.serverName = key.GetValue("SQLserver").ToString();
this.timeout = key.GetValue("timeout").ToString();
this.Database = key.GetValue("database").ToString();
this.logTable = key.GetValue("table_log").ToString();
this.budgetTable = key.GetValue("table_budget").ToString();
this.personsTable = key.GetValue("table_persons").ToString();
this.tempTable = key.GetValue("table_temp").ToString();
this.cashiersDB = key.GetValue("cashiersDB").ToString();
this.customersTbl = key.GetValue("cashiersCustomersTable").ToString();
key.SetValue("version", version);
if (this.serverName == null || this.timeout == null || this.Database == null || this.logTable == null
|| this.budgetTable == null || this.personsTable == null || this.tempTable == null)
{
Console.WriteLine("One of the values could not be loaded.");
return false;
}
}
else
{
Console.WriteLine("Key is null.");
return false;
}
return true;
}
}
私がワークステーションでコードを実行すると、すべてが完璧です。私がサーバ上でそれを行うとき、それはfalseを返し、 "Key is null"と書いています。
Registry.LocalMachineの代わりにRegistry.CurrentUserを使用してコードをコンパイルすると、trueを返します(もちろん、異なる場所の値は同じです)。
どうしたのですか?私はドメイン管理者であり、また自分自身に明示的に完全な制御権を与えている。HKEY_LOCAL_MACHINE \ SOFTWARE \ Company \ Application \ NightJob \
アイデアはありますか?
ありがとうございました。これは問題を解決しました。多くのお礼ありがとうございます – josibu
@ josibuようこそ – tdog