c#. App.exe.config 没有使用
我已经部署了一个从网络服务器下载的应用程序。这是使用 Visual Studio 安装项目生成的 msi 安装的普通桌面应用程序。服务器的地址作为应用程序设置存储在 app.exe.config 中。后来,我使用记事本更改了 app.exe.config 中的地址,但该应用程序仍然使用旧的网址。事实上,我尝试删除 app.exe.config,应用程序仍然设法获取旧网址???
有人可以解释发生了什么事吗?
抱歉,如果它让一些人感到困惑。使用 C# 项目的属性 -> 来管理设置设置页面。该项目名为updatesdownloader,我编辑的实际文件是updatesdownloader.exe.config,它与exe位于同一文件夹中。
我用来读取服务器地址字符串的代码是:
Server updateServer = new Server(new Uri(UpdatesDownloader.Properties.Settings.Default.Server));
I have deployed an app that downloads from a web server. This is a normal desktop app installed using a msi produced by Visual Studio setup project. The address of the server is stored in app.exe.config as an application setting. Later, I change the address in app.exe.config using notepad, but the app is still using the old web address. In fact, I tried deleting the app.exe.config and the app still managed to get the old web address?????
Can someone explain what is happening.
Sorry if it confused some people. The settings are managed using the C# project's properties -> Settings page. The project is called updatesdownloader and the actual file I edit is updatesdownloader.exe.config which is in the same folder as the exe.
The code I used to read the server address string is:
Server updateServer = new Server(new Uri(UpdatesDownloader.Properties.Settings.Default.Server));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您要更改的文件在哪里?该设置是用户设置还是应用程序设置?
您可能需要在用户计算机上的 %AppData% 或 %ProgramData% 文件夹中查找您的设置。
Where is the file that you are changing? Is the setting a user setting or an application setting?
You may want to look for your settings in the %AppData% or %ProgramData% folders on the user's machines.
您需要使用
ConfigurationManager.RefreshSection
来获取包含您的设置的自定义部分。查看示例 关于如何创建自定义部分
You need to us
ConfigurationManager.RefreshSection
for a custom section that contains your settings.Check this for an example on how to create a custom section
您确定该地址没有硬编码在应用程序本身中吗?我确信,如果您使用
ConfigurationManager.AppSettings["SomeUrl"];
引用 URL 并尝试访问该 URL,则如果该文件不存在,则会失败。Are you sure the address is not hard-coded in the app itself? I would be sure that if you made reference to a URL using
ConfigurationManager.AppSettings["SomeUrl"];
and attempted to go there, it would fail if the file did not exist.