【发布时间】:2011-09-30 10:23:26
【问题描述】:
让我先解释一下场景。
我已经从一个安装库安装了多个服务副本(比如 10 个)。现在我想更新其中一个 dll。我需要停止所有服务,更新 dll 并重新启动服务。
为了避免这种情况,我在代码中使用了 ShadowCopying。这样可以在不停止所有服务的情况下更新 dll。如下。
static void Main(string[] args)
{
AppDomain.CurrentDomain.SetCachePath(@"C:\Cache");
AppDomain.CurrentDomain.SetShadowCopyPath(AppDomain.CurrentDomain.BaseDirectory);
AppDomain.CurrentDomain.SetShadowCopyFiles();
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new SampleService(serviceName)
};
ServiceBase.Run(ServicesToRun);
}
现在我正在尝试通过 app.config 文件实现相同的功能,如下所示,来自 Asp.Net
<hostingEnvironment
idleTimeout="Infinite"
shutdownTimeout="30"
shadowCopyBinAssemblies="true" />
有什么建议吗?
【问题讨论】:
-
你根本没有说这个问题。你有什么问题吗?请不要让我们尝试您的代码并让我们谈论问题。
-
我正在尝试单独使用配置文件实现影子复制,就像 ASP.net 所做的那样。没有在代码中创建应用程序域...我被卡住了...
标签: c# service appdomain appdomainsetup