在C#桌面应用程序替代(用户范围)设置应用程序、范围、桌面、用户

2023-09-06 08:47:27 作者:墨痕未染泪痕一笺

您好 1)我使用Visual Studio 2008(C#)

Hello 1) I use Visual Studio 2008 (C#)

2)我希望我的桌面应用程序记住特定设置(preferences)分别为每个用户。

2) I want my desktop application to "remember" certain settings (preferences) for every user individually.

3)应用程序将使用自己的用户(登录名+密码)的数据库,所以他们什么都没有做与Windows帐户。

3) The application would use its own database of users (logins + passwords), so they have nothing to do with Windows accounts.

我怎样才能实现这个目标?试图找到答案

How can I accomplish that? Trying to find an answer

4)我发现在MSDN =>的 http://msdn.microsoft.com/en-us/library/aa730869%28VS.80%29.aspx - 但

4) I've found the "Using Alternate Sets of Settings" subject on MSDN => http://msdn.microsoft.com/en-us/library/aa730869%28VS.80%29.aspx - but

5)它表明,即使这些替代的设置需要在设计时要添加。这是一个有点问题,因为:

5) it suggests that even these alternative settings need to be added in design time. That's a bit of a problem, because:

6)我事先不知道做什么,有多少用户会在数据库中 - 我想要的主用户(管理员)有增加更多的选择帐户,他想要的任何时间

6) I don't know in advance, how many users would be in the database - and I want the "main user" (admin) to have an option of adding more accounts any time he wants.

所以, 7)如何实现这一目标?

So 7) how do I accomplish that?

到目前为止,我想到了: 8)使用独立存储的文件? (但他们也被用户范围在提到Windows帐户的意义)

So far I thought about: 8) using isolated storage files? (but they, too, are user-scoped in the sense of referring to Windows accounts)

9)派生自己的类从ApplicationSettingsBase类,并用另存为()方法(它没有默认值)提供呢?

9) deriving my own class from ApplicationSettingsBase class and supplying it with a SaveAs() method (which it lacks by default)?

感谢您的任何答复/建议。 如果我的问题不是很清楚,我很高兴澄清

Thanks for any answers / suggestions. If my problem is not quite clear, I'm happy to clarify

推荐答案

如果您有存储用户和密码的数据库,为什么不保存应用程序设置有作为?我在你使用SQL Server的假设(出preSS或商业)

If you have a database that stores users and passwords, why not store the application settings there as well? I'm assuming you're using SQL Server (Express or commercial)

所有的设置在.NET的关键,值对,我不明白为什么你不能做到这一点完全一样的功能与名称值对数据库中的。

All "Settings" are in .NET are key, value pairs, and I don't see why you couldn't accomplish this exact same functionality with a name value pair in the database.

我发现,在设置,配置管理工具是混乱而复杂的使用,所以如果你有与用户在它的数据库已经,你还不如充分利用现有的基础设施。

I've found that the "Settings" and Configuration management tools are confusing and tricky to use, so if you have a database with users in it already, you might as well leverage your existing infrastructure.