VSWebSite.PreCompileWeb fails when data connections are open

I recently noticed that VSWebSite.PreCompileWeb fails whenever the selected web site includes a database file that is open in the Server Explorer. An error is given that the database file is in use by another process. This is not strictly an extensibility problem though; the same error occurs when using the Publish Web Site wizard in the IDE or trying to use the aspnet_compiler.exe directly.

Is there a workaround for this issue Simply closing the Server Explorer won't work, but closing the connection of the open database file does. How can that be accomplished programmatically

Thanks,
Bryan




Answer this question

VSWebSite.PreCompileWeb fails when data connections are open

  • DaveRivera

    Thanks to Antoine Cote and Brad Bartz at Microsoft for the solution.

    string[] files;
    // ... populate the files array with the with the full paths of all files that should be released

     IVsTrackProjectDocuments3 vsTrackProjectDocuments = serviceProvider.GetService(typeof(SVsTrackProjectDocuments)) as IVsTrackProjectDocuments3;< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

     vsTrackProjectDocuments.HandsOffFiles((uint)__HANDSOFFMODE.HANDSOFFMODE_ReadAccess, files.Length, files);

     



  • VSWebSite.PreCompileWeb fails when data connections are open