Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to add a service reference - locked/read only

Tags:

c#

asp.net

wcf

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.

like image 334
user2084666 Avatar asked Jun 10 '14 18:06

user2084666


3 Answers

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.

  1. set source control plugin to None
    • go to TOOLS > Options > Source Control.
  2. add service reference
  3. set the source control plugin to the original value
like image 162
Prokurors Avatar answered Oct 10 '22 02:10

Prokurors


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.

like image 35
Tascalator Avatar answered Oct 10 '22 03:10

Tascalator


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:

  1. Make sure if you copy paste from location where there was source control then remove source control specific files.

  2. Make sure folder is not locked & also is not read-only. If it is so, then remove read-only from the folder.

  3. Make sure visual studio is not in debugging mode while adding reference.

  4. If above not works, close visual studio & restart it.

  5. Make sure Visual Studio is started as "Run as Administrator".

  6. Finally if all above doesn't work try restart machine.

Let me know if it works or not.

like image 44
Pranav Singh Avatar answered Oct 10 '22 04:10

Pranav Singh