在可能部署在 Citrix 环境中的 .Net Winforms 应用程序中存储设置的最佳实践是什么?

发布于 2024-10-01 23:07:53 字数 677 浏览 0 评论 0原文

我有一个桌面应用程序,在第一次执行时提示输入数据库的连接详细信息,然后我想保留它们以供将来使用(作为加密字符串),以便用户下次启动应用程序时可以重新使用它们。现在客户端运行一个我以前从未真正接触过的 Citrix 环境,我想确保这个加密的数据库字符串以这样的方式保存,以便用户无论从哪里登录都可以使用它 - 我认为我的意思是应用程序需要了解其漫游配置文件中的此设置,但这是我之前不必真正担心的事情,所以我只是检查是否有任何我需要的陷阱知道。

通常我只使用 .Net 中的 My.Settings 命名空间,但这会在这种环境中减少它吗?

我很感激任何知道保存用户设置的“最佳实践”的人,这样漫游用户从新位置登录时就不会再次输入其设置。

以这种方式设置数据库连接的原因是,用户可以在测试数据库和实时数据库之间切换(相同的数据库,不同的服务器)。

将实时和测试连接字符串存储在 app.config 中并允许管理员在安装后手动更新它们,然后在 UI 中提供从测试到实时的切换会更好吗?

我通常在 ASP.NET 网站上工作,所有内容都在 web.config 中愉快地生活,所以这有点超出了我的舒适区。我可以在书中看到很多选项,但我想知道是否有人对哪种技术最适合他们有任何建议?

我正在使用 VB.Net 3.5 (Visual Studio 2010)。这是一个 Windows 窗体项目,在实际的数据库访问发生的解决方案中包含一些 .dll 库。

I have a desktop application that on first execution prompts for the connection details to the database and then I want to retain them for future use (as an encrypted string) so that the next time the user starts up the app they can be re-used. Now the client runs a citrix environment which I haven't really had any exposure to before and I want to make sure that this encrypted database string is saved in such a way that it is available to the user wherever they log in from - I think that what I'm saying is that the application needs to be aware of this setting in their roaming profile but this is something I haven't really had to worry about before so I'm just checking whether there are any gotchas that I need to be aware of.

Normally I just use the My.Settings namespace in .Net but is that going to cut it in this environment?

I'd appreciate anyone who knows a "best practice" for saving user settings in such a way that a roaming user will not be challenged to enter their settings again when they log in from a new location.

The reason for setting the DB connection in this way is that there is a Test and a Live database that the user can switch between (identical databases, different servers).

Would it be better to store the live and test connection strings in the app.config and allow the admins to manually update them after installation and then provide a switch to go from test to live in the UI?

I generally work on asp.net sites where everything lives happily in the web.config so this is a bit of a step outside my comfort zone. I can see quite a few options in the books but I'm wondering if anyone has any advice on which technique works best for them?

I'm using VB.Net 3.5 (Visual Studio 2010). It's a windows forms project with a handful of .dll libraries in the solution where the actual DB accessing takes place.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

悲念泪 2024-10-08 23:07:53

正如您已经写过的,您需要确保保存的设置最终位于配置文件的漫游部分。它可以是注册表配置单元 HKEY_CURRENT_USER,也可以是解析为 %USERPROFILE%\AppData\Roaming 的文件夹 %APPDATA%(在 Vista 和更高版本上,也可以是旧操作系统上特定于区域设置的漫游 AppData 文件夹)。

在 .NET 中,用户特定的设置可以存储在用户配置文件的漫游部分和本地部分中。为了使设置能够漫游,“Roaming”属性需要设置为 true。请参阅本文以获取说明以及设置实际保存的路径:

http:// /www.codeproject.com/KB/vb/appsettings2005.aspx

As you already wrote, you need to make sure your saved settings end up in the roaming part of the profile. That can either be the registry hive HKEY_CURRENT_USER or the folder %APPDATA% which resolves to %USERPROFILE%\AppData\Roaming (on Vista and newer, but also to the locale-specific roaming AppData folder on older operating systems).

In .NET, user-specific settings can be stored both in the roaming and local parts of the user profile. In order for settings to roam, the "Roaming" property needs to be set to true. See this article for an explanation and also for the paths the settings actually get saved at:

http://www.codeproject.com/KB/vb/appsettings2005.aspx

旧夏天 2024-10-08 23:07:53

如果您事先知道连接字符串,则可以将它们存储在 app.config 中,并要求用户在应用程序开始时通过 ComboBox 选择连接。

如果您事先不知道连接字符串,我可以想到以下选项:
1- 使用您知道其连接字符串的数据库或本地数据库、SqlServerCE .sdf 文件来存储这些信息。
2- 使用 .Net 中的用户设置,可通过 C# 中的 Properties.Settings.Default.NameofSetting 访问。

If you know the connection strings beforehand you can store them in the app.config and ask the user at the begining of the application to choose the connection via a ComboBox for example.

If you don't know the connections strings in advance, I can think of the following options:
1- Use a database that you know its connection string or a local database, SqlServerCE .sdf file, to store these information.
2- Use user settings in .Net accessible via Properties.Settings.Default.NameofSetting in C#.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文