您好
我使用卷影副本时,其在服务use.When开始更新我的DLL,DLL运行作为结果从shadowcopied域的dll文件仍然锁定和可更新also.It工作在我的机器不错的。
但是,当我们尝试其他机器上运行的服务,服务抛出以下错误:
"指定的用户不具有有效的文件,无法加载assmebly"
cachepath越来越创建的,但问题是其无法从cachepath加载。会是什么原因呢?
下面我所用的代码中找到:
预先感谢
string _path="C:\\TTG\\Tools\\TtgUpdate\\"
AppDomainSetup environment = new AppDomainSetup()
{
ApplicationBase = Path.GetDirectoryName(_path)
};
// instantiate the security policy for the application domain...
Evidence evidence = AppDomain.CurrentDomain.Evidence;
//Enable shadow copy option for the newly created domain for the purpose to
// update TTGUpdateDLL when in use
AppDomain.CurrentDomain.SetShadowCopyFiles();
AppDomain.CurrentDomain.SetShadowCopyPath(Path.GetDirectoryName(_path));
environment.ShadowCopyDirectories = Path.GetDirectoryName(_path);
environment.ShadowCopyFiles = "true";
string _installPath = WindowsRegistry.Instance.Read(WindowsRegistry.REGKEYS.HKLM, "\\Software\\TTGTT\\System", "InstallDirectory");
environment.CachePath = _installPath + "\\Tools\\TtgUpdate\\AssemblyCatch";
environment.ApplicationName = "AppName";
string _shadowCopyPath = environment.CachePath + "\\" + environment.ApplicationName;
// instantiate the application domain...
_appDomain = AppDomain.CreateDomain(friendlyName, evidence, environment);