如何部署,每个用户的自定义设置桌面.NET应用程序 [英] How to deploy a desktop .Net application with custom settings per user

查看:86
本文介绍了如何部署,每个用户的自定义设置桌面.NET应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎是一个简单的问题,但intergoogles都没有的那种。

This seems like a simple question but the intergoogles have not been kind.

我有一个C#桌面应用程序。有一定的场所中需要每个客户被定制,例如每个客户的组织的名称,在其他方面独立的应用程序的实际的功能,因此不需要被编译成它

I have a C# desktop application. There are certain properties that need to be customized per customer, such as each customer's organization's name, that are otherwise independent of the actual functionality of the application and therefore do not need to be compiled into it.

什么是最好/ preferred方法来拉这个数据出来的应用程序,在VS中进行管理(2008年),并将其部署到用户的桌面?

What is the best/preferred method to pull this data out of the application, manage it in VS (2008), and deploy it to customers' desktops?

举例来说,假设我有两个独立的组织两个不同的用户,所以他们每个人都需要一组独立的设置。难道我只是创造了他们每个人一个新的app.config文件?我将不得不重新安装项目为每个用户,以适应新的app.config文件?

For example, say I have two separate users in two separate organizations, so they each need a separate set of settings. Do I just create a new app.config file for each of them? Would I have to rebuild the setup project for each user in order to accommodate that new app.config file?

谢谢

推荐答案

应用程序设置子系统允许您创建强类型的设置,在每个用户或每个应用程序。只需右键单击该项目,选择属性,然后单击设置选项卡上。

The Application Settings subsystem allows you to create strongly-typed settings, on a per-user or per-application basis. Just right-click the project, choose Properties, and click on the Settings tab.


应用程序设置概述

应用程序设置既涉及   通过提供一种简单的方法需要   同时存储应用程序范围和   客户端上的用户范围设置   计算机。使用Visual Studio或   code编辑器,你定义的设置   通过指定特定属性的   名,数据类型,以及范围   (应用程序或用户)。你甚至可以   将相关的设置到一个名为   集团以方便使用和可读性。   一旦确定,这些设置   坚持和回读入内存   在运行时自动。可插拔   架构实现了持久性   机制来改变,但由   默认情况下,本地文件系统   用了。

Application settings addresses both needs by providing an easy way to store both application-scoped and user-scoped settings on the client computer. Using Visual Studio or a code editor, you define a setting for a given property by specifying its name, data type, and scope (application or user). You can even place related settings into named groups for easier use and readability. Once defined, these settings are persisted and read back into memory automatically at run time. A pluggable architecture enables the persistence mechanism to be changed, but by default, the local file system is used.

应用程序设置的工作方式   持续数据作为XML不同   配置(的.config)文件,   对应于是否设置   是应用程序范围或用户范围。   在大多数情况下,应用程序作用域   设置为只读;因为他们   有计划的信息,你会   通常并不需要覆盖它们。   相比之下,用户范围设置可   读取和运行安全写入   时间,即使你的应用程序运行   在部分信任。欲了解更多   有关部分信任的信息,请参阅   在Windows安全窗体概述。

Application settings works by persisting data as XML to different configuration (.config) files, corresponding to whether the setting is application-scoped or user-scoped. In most cases, the application-scoped settings are read-only; because they are program information, you will typically not need to overwrite them. By contrast, user-scoped settings can be read and written safely at run time, even if your application runs under partial trust. For more information about partial trust, see Security in Windows Forms Overview.

当你添加一个设置,Visual Studio创建的设置类的强类型属性。它还创建了应用程序配置文件中的条目。为应用程序的设置,这是该设置的实际值。你可以在安装时改变它,如果你喜欢。对于用户设置,这是设置的默认值。用户可以在运行时更改值。然后,您可以调用Save方法来保存更改值。的用户设置的当前值存储在存储在正确的每个用户文件夹中的文件user.config,基于用户是否正在漫游,局部等

When you add a setting, Visual Studio creates a strongly-typed property in the settings class. It also creates an entry in the application config file. For an Application setting, this is the actual value of the setting. You could change it at installation time, if you like. For a User setting, this is the default value of the setting. The user can change the value at runtime. You can then call the Save method to save the changed value. The current value of User settings is stored in a user.config file stored in the correct per-user folder, based on whether the user is roaming, local, etc.

这真是非常好的与Windows窗体一起使用时,由于窗体和控件的各种属性可以在设计时绑定到应用程序设置。这意味着,在应用程序启动时,这些特性将它们的初始值从设置。如果值在运行时更改,该设置会改变。然后,您可以在应用程序退出之前保存更改的设置。然后,他们将在应用程序再次启动时会自动使用。这需要非常少的code。

It's really very nice when used with Windows Forms, since various properties of forms and controls can be bound to application settings at design time. This means that when the application starts, these properties will take their initial values from the settings. If the values change at runtime, the settings will change. You can then save the changed settings before the application exits. They will then automatically be used when the application starts again. This takes very little code.

尽管这些为Windows窗体在.NET 2.0中创建,我用它们与其他项目类型,尤其是单元测试项目。当然,在那种情况下,你有没有每用户设置。

Even though these were created for Windows Forms in .NET 2.0, I've used them with other project types, especially unit test projects. Of course, in that situation, you have no per-user settings.

这篇关于如何部署,每个用户的自定义设置桌面.NET应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆