2017-10-10 8 views
1

다음 코드를 사용하여 서비스를 설치합니다.AssemblyInstaller 서비스가 dll 파일에 대한 액세스를 차단하도록 설치합니다.

string[] commandLineOptions = new string[0]; 
System.Configuration.Install.AssemblyInstaller installer = new System.Configuration.Install.AssemblyInstaller(path, commandLineOptions); 
installer.UseNewContext = true; 
installer.Install(null); 
installer.Commit(null); 

설치 후에는 서비스가 포함 된 dll 파일을 제거하는 동안 설치가 잘되지만 액세스가 거부되어 수행 할 수 없습니다. 응용 프로그램을 닫으면 문제가 사라집니다 (서비스가 설치되어 있음). 그것을 해결하는 방법?

답변

0

설치에 Dispose()를 호출 시도하거나 "사용"으로 코드를 포장 : AssemblyInstaller에서

using (var installer = new AssemblyInstaller(path, commandLineOptions)) 
{ 
    installer.UseNewContext = true; 
    installer.Install(null); 
    installer.Commit(null);  
} 

MSDN에 :

Dispose() Releases all resources used by the Component.(Inherited from Component.)

+0

모두 작동하지 않습니다 – quarandoo