让我先解释一下场景。
我已经从一个安装库安装了多个服务副本(比如 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" />
有什么建议么?