I install a WCF service with this command line:
String installParams = Service1.exe;
If there is an error, this method throw an InvalidOperationException, that I catch.
Before I call this function, I copy the Service1.exe from Service.exe with File.Copy method.
If there is an error during the installation, I want to delete the file copy Service1.exe, but it is locked.
I try in debug mode to execute the InstallHelper method and with explorer find the file and delete it, but is still locked until I close my application.
What can I do?
How I can release the resources?
I try to install the service executing the InstallUtil.exe form my application, but I need to catch if there is some errors during the installation and do some actions.
Thanks to all for help!!!
Went through the same issue, so if someone has again the same issue, it may help :
The file is still locked by your call to ManagedInstallerClass. You need to free it before trying to kill it.
The issue is, you have no handle over the file. You just gave Manadged.InstallHelper a path to it.
GC.Collet() should work in theory but didnt in my case. I had to free the class who was calling InstallHelper to be able to delete the file.
Hopes it help,