tags:

views:

18

answers:

0

We developed a small MMC snap-in that installs various components of the application. In particular, it registers .NET assemblies with COM+ using System.EnterpriseServices.RegistrationHelper. The logic is simple: first, uninstall existing assembly, then copy new file over, then install the new assembly. The code looks like this:

if (File.Exists(destination))
{
   try
    {
       new RegistrationHelper().UninstallAssembly(destination, ComPlusHelper.ApplicationName);
    }
    catch (Exception ex)
    {
        Log.LogError(...);
    }
}
File.Copy(source, destination, true);

However, the File.Copy call fails with the error "The process cannot access the file xxxx because it is being used by another process". I spent a day reading MSDN and googling, but couldn't find a solution.

Does anyone have any suggestions?