一旦运行,App.config不会“刷新”? [英] App.config doesn't 'refresh' once runned?

查看:65
本文介绍了一旦运行,App.config不会“刷新”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有运行的Windows服务(用VB.NET制作),并希望能够不时更改
一些参数通过在App.config中更改它们。

但似乎应用程序没有使用

App.config中的更改值,但继续使用启动期间的值。


有没有办法让应用程序使用App.config中的新值?

是我应该运行哪种刷新功能?或者我应该以另一种方式做这个吗?


谢谢,


彼得

Hi,

I have a Windows Service running (made in VB.NET), and wanted to be able to
change from time to time some parameters by changing them in the App.config.
But it seems that the application doesn''t use the changed values in the
App.config, but continue to use the values that were there during start-up.

Is there a way to let the application use the new values in the App.config?
Is there kind of some ''refresh'' function that I should run? Or should I do
this on an other way?

Thanks,

Pieter

推荐答案

我可能错了,但是IIRC app.config是编译过程的一部分,所以我认为它很可能是你必须重新编译项目,除非你在运行时专门设置它以查看该文件(或者知道它应该是
)。

" DraguVaso"写道:
I might be wrong but IIRC the app.config is part of the compile process, so I
think it''s likely that you would have to recompile the project, unless you
specifically set it to look in that file during runtime (or know that it''s
supposed to).
"DraguVaso" wrote:


我有一个Windows服务运行(用VB.NET制作),并希望能够从通过在App.config中更改它们来定时一些参数。
但似乎应用程序没有使用
App.config中的更改值,但继续使用的值是在启动期间有没有。

有没有办法让应用程序使用App.config中的新值?
是否有一些刷新功能,我应该跑?或者我应该在其他方面做什么?

谢谢,

Pieter
Hi,

I have a Windows Service running (made in VB.NET), and wanted to be able to
change from time to time some parameters by changing them in the App.config.
But it seems that the application doesn''t use the changed values in the
App.config, but continue to use the values that were there during start-up.

Is there a way to let the application use the new values in the App.config?
Is there kind of some ''refresh'' function that I should run? Or should I do
this on an other way?

Thanks,

Pieter



那不是真的。 App.Config被复制到exename.exe.config。然后在运行时阅读

而无需任何重新编译。


- Sahil Malik

你可以通过我的博客与我联系< a rel =nofollowhref =http://www.dotnetjunkies.com/weblog/sahilmaliktarget =_ blank> http://www.dotnetjunkies.com/weblog/sahilmalik



" Bonj" <博** @ discussions.microsoft.com>在留言中写道

news:88 ********************************** @ microsof t.com ...
That''s not true. App.Config is copied to exename.exe.config. It is then read
at runtime without needing any recompilation.

- Sahil Malik
You can reach me thru my blog http://www.dotnetjunkies.com/weblog/sahilmalik


"Bonj" <Bo**@discussions.microsoft.com> wrote in message
news:88**********************************@microsof t.com...
我可能错了,但是IIRC app.config是编译过程的一部分,所以
我认为你很可能会这样做必须重新编译项目,除非你专门设置它在运行时查看该文件(或知道它应该是)。

" DraguVaso"写道:
I might be wrong but IIRC the app.config is part of the compile process, so
I
think it''s likely that you would have to recompile the project, unless you
specifically set it to look in that file during runtime (or know that it''s
supposed to).
"DraguVaso" wrote:


我有一个Windows服务运行(用VB.NET制作),并希望能够

通过在App.config中更改它们来不时更改一些参数。
但似乎应用程序没有使用
App.config中更改的值,但继续使用
启动期间的值。

有没有办法让应用程序使用
App.config中的新值?
谢谢,

Pieter
Hi,

I have a Windows Service running (made in VB.NET), and wanted to be able
to
change from time to time some parameters by changing them in the
App.config.
But it seems that the application doesn''t use the changed values in the
App.config, but continue to use the values that were there during
start-up.

Is there a way to let the application use the new values in the
App.config?
Is there kind of some ''refresh'' function that I should run? Or should I
do
this on an other way?

Thanks,

Pieter



在编译期间(或之后),app.config文件只是复制到

目标目录并重命名为< your_app_name> .exe的.config。然后在应用程序启动时阅读




我不知道有任何重新加载配置的方法。该文件包含了无法重新加载的应用程序启动所需的信息(如运行时

依赖关系等)。


如果你需要在运行时更改参数,我建议您使用

注册表或一些SQL数据库作为参数或使用另一个

配置文件(说app.xml)和FileSystemWathcher等,但我猜

这太复杂了。


HTH,

Stefan


" Bonj" <博** @ discussions.microsoft.com>在留言中写道

news:88 ********************************** @ microsof t.com ...
During (or after) compilation, the app.config file is just copied to the
target directory and renamed to <your_app_name>.exe.config. It''s then read
on application startup.

I''m not aware of any way of reloading the configuration. The file contains
information that''s required for application startup (like runtime
dependencies, etc.) which could not be reloaded.

If you need to change parameters during runtime, I suggest you either use
the registry or an some SQL database for your parameters OR use another
configuration file (say app.xml) and a FileSystemWathcher etc., but I guess
that would be way too complicated.

HTH,
Stefan

"Bonj" <Bo**@discussions.microsoft.com> wrote in message
news:88**********************************@microsof t.com...
我可能错了,但是IIRC app.config是编译过程的一部分,所以
我认为你很可能会这样做必须重新编译项目,除非你专门设置它在运行时查看该文件(或知道它应该是)。

" DraguVaso"写道:
I might be wrong but IIRC the app.config is part of the compile process, so
I
think it''s likely that you would have to recompile the project, unless you
specifically set it to look in that file during runtime (or know that it''s
supposed to).
"DraguVaso" wrote:


我有一个Windows服务运行(用VB.NET制作),并希望能够

通过在App.config中更改它们来不时更改一些参数。
但似乎应用程序没有使用
App.config中更改的值,但继续使用
启动期间的值。

有没有办法让应用程序使用
App.config中的新值?
谢谢,

Pieter
Hi,

I have a Windows Service running (made in VB.NET), and wanted to be able
to
change from time to time some parameters by changing them in the
App.config.
But it seems that the application doesn''t use the changed values in the
App.config, but continue to use the values that were there during
start-up.

Is there a way to let the application use the new values in the
App.config?
Is there kind of some ''refresh'' function that I should run? Or should I
do
this on an other way?

Thanks,

Pieter



这篇关于一旦运行,App.config不会“刷新”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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