7

I have run into this several times now:

 An error was raised by libgit2. Category = Os (Error). 

Which sometimes causes this or similar error while i am writing code:

Failed to open '.../App_Data/....mdf': 
The process cannot access the file because it is being used by another process.

When this happens i can't code without restarting my Visaul Studio 2012.

I think it's being caused by Source Control - Git as i don't remember having this problem before i installed the Git extension for Visual Studio and Team Foundation.

Has anyone else run into this and how did they solve it?

Komengem
  • 3,662
  • 7
  • 33
  • 57

3 Answers3

8

I just ran into this today with a new Visual Studio project. The project was using the autogenerated .gitignore which had the following entries which I thought should have covered the .mdf file just fine:

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf

However I still received:

An error was raised by libgit2. Category = Os (Error). 
Failed to open '.../App_Data/....mdf': 
The process cannot access the file because it is being used by another process.

So I edited the .gitignore, preceding each entry with an asterisk-slash, like so:

# SQL Server files
*/App_Data/*.mdf
*/App_Data/*.ldf

And I was able to continue business as usual.

Douglas Ludlow
  • 10,754
  • 6
  • 30
  • 54
  • This is slowing me down, i will get rid of `git` from my project – Komengem Apr 25 '13 at 07:31
  • 1
    I'm getting this on .dbmdl too even though I have them .gitignored! Really frustrating. Works fine from Git GUI though on the same repo and if I check it all in then the VS plugin will work for a while again until it doesn't. – Jason Kleban Jul 17 '13 at 18:34
  • @uosɐſ You may have to remove the files in question from the actual repo. .gitignore ignores files going forward. – Douglas Ludlow Jul 17 '13 at 20:09
  • I previously deleted this .dbmdl file (as it gets regenerated) and checked in the deletion. Doing a `git rm --cached blah.dbmdl` says that the path doesn't exist (it shows the correct path and I only have one branch). – Jason Kleban Jul 18 '13 at 11:44
3

I would want to add it is maybe just as simple as => Close your database connexion :)

Remi Marenco
  • 169
  • 4
0

I had the same error. IIS express was running in the system tray. When I killed IIS Express everything committed as expected.