Unable to add a service reference - locked/read only
Whenever I go to add a service reference I get the error:
Failed to add Service Reference 'Servicereference1.reference'
Error: Unable to check out the current file. The file may be read-only or locked, or you may need to check the file out manually.
I already had a service reference in the project, but it broke somehow and gave me an error that stated:
Could not find default endpoint element that references contract (servicename)
The endpoints in both the web.config and the service reference config were the same (localhost)
I also could not update that reference as I would get the same 'unable to check out current file' error.
EDIT: The problem isn't native to just this project. I tried to make a new, totally separate project, and add a service reference to that and I got the same error.
Solution 1:
I had the same error - what I found, was that there are problems if you have source control plugin "Microsoft Git provider" selected (my WCF solution was not added to source control!) and you try to add service reference.
- set source control plugin to None
- go to TOOLS > Options > Source Control.
- add service reference
- set the source control plugin to the original value
Solution 2:
I know this has been answered, but before trying everything else in the answers, restart visual studio. This just happened to me and 4 other people in my WCF class. Seems to be a problem with visual studio 2013 and not 2012.
Solution 3:
As you have already cleared there is no source control involved(which seems to be cause of problem to me), you can try these steps:
Make sure if you copy paste from location where there was source control then remove source control specific files.
Make sure folder is not locked & also is not read-only. If it is so, then remove read-only from the folder.
Make sure visual studio is not in debugging mode while adding reference.
If above not works, close visual studio & restart it.
Make sure Visual Studio is started as "Run as Administrator".
Finally if all above doesn't work try restart machine.
Let me know if it works or not.
Solution 4:
Maybe it's a bit late, but if someone has the same problem, I solved it running VS2013 as administrator.
Solution 5:
Go to Debug menu and click on (Options and Settings)
Select Source Control.
Under Current Source ControlPlug-in drop down select none
Then click ok to save chnages,Now you can add service reference.