2

When trying to publish our website on Windows Server 2008 R2, we are seeing the following error. Error 4 The process cannot access the file 'C:\Users\Student\Desktop\CSFP Front-End\App_Data\ASPNETDB.MDF' because it is being used by another process.
We don't understand what else could be using the data file. web.config looks like this

<connectionStrings>
    <add name="FBConnectionString" connectionString="Data Source=SERVER4;Initial Catalog=AITP;Integrated Security=True" providerName="System.Data.SqlClient" />
    <add name="ASPNETDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Student\Desktop\CSFP Front-End\App_Data\ASPNETDB.MDF;Integrated Security=True;User Instance=True"/>
  </connectionStrings>
  <system.web>

It runs fine locally, and the roles and users work as well. "Build Web Site" also works just fine, but when we are trying to publish the website it throws the error. Any ideas?

Andrey
  • 1,629
  • 13
  • 37
  • 65
  • Seems you can only deploy changes through sql script..http://forums.asp.net/p/1721743/4602266.aspx/1?The+process+cannot+access+the+file+App_Data+ASPNETDB+MDF+because+it+is+being+used+by+another+process+when+publish+the+website – Sunny Mar 15 '13 at 01:56
  • i red that and it doesn't help me – Andrey Mar 15 '13 at 02:05

2 Answers2

5

while publish the project, first detach the database file. Then publish it will work fine. For detaching right click on App_Data->ASPNETDB.MDF, detach...

felix Antony
  • 1,450
  • 14
  • 28
2

The simplest solution could be to simply close the .mdf file and restart Visual Studios. I've had to do this when felix's method doesn't work.

Another superstition I try is killing the "SQL Server" process with the Task Manager.

hubatish
  • 5,070
  • 6
  • 35
  • 47