Unable to add a service reference - locked/read only - c#

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.

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

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.

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.

Maybe it's a bit late, but if someone has the same problem, I solved it running VS2013 as administrator.

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.

Oddly enough I was experiencing this in VS 2019, using git source control. I was able to resolve this by simply cleaning and rebuilding the project containing the service reference...
EDIT: If you already have a service reference that you're attempting to update you might have to delete it and add it again

Looks like some Visual studio file has gone corrupted. Try deleteing the reference completely then generate the reference using svcutil {http://{service}/metadataEndpoint} ( I assume it is WCF) or (use wsdl.exe for webservices), then get the client proxy and put it in the project to use it. See if that works fine.

Shutting down your default source control to add reference is horrible. #ScottG said above, and does work.. just start VS as administrator - that works, and you dont have to mess with your environment. VS 2013 UP-5 still has this issue.

Check if your files are read only, if yes remove the read only attribute and restart the visual studio and try to add service reference.
it worked for me like this.

Make sure, your folder in IIS where your services put (I mean the physical file; .svc) is not open or even selected in file manager. It's work for me, but before I almost went mad to find error.

My issue was related to source control but I found an easy work-around. Open the App.config file and make any change and save it. This unlocked the file and allowed me to add the service reference.

ok, I am last here and spend 1 day to search the solution , nothing was wrong in my code and I tried multiple times restart machine , close reopen visual studio but nothing worked .In my case there were some update in visual studio 2019 and that was causing the issue. After installing the update I was able to update the service reference. Hope this will be helpful for some one .

Related

Rebuild Solution - "Parameter not supported by the "SignFile" Task

I'm trying to create a small Excel-Addin with just 1 Project in the Solution.
I downloaded the Tools at http://social.msdn.microsoft.com/Forums/vstudio/en-US/0c144a87-917a-4eb1-8716-da61f7efdafc/office-developer-tools-for-visual-studio-2013-march-2014-update-now-available?forum=lightswitch and could create a Add-In.
I can even debug it, but as soon as I rebuild the Solution, i get the 2 following errors:
Error 1 The "TargetFrameworkVersion" parameter is not supported by the
"SignFile" task. Verify the parameter exists on the task, and it is a
settable public instance property.
Error 2 The "SignFile" task could
not be initialized with its input parameters.
Funny enought, on another machine the rebuilding is working perfectly and as far as the other developer knows he didn't do anything special.
I checked a bout abut this SignFile Task, f.e. :http://msdn.microsoft.com/en-us/library/ms164304.aspx , but when I unload the Project and check the file, there are no such entries there.
On the problematic machine I created a new AddIn-Solution and run even on a empty Solution in the exact same problems.
P.S.: I can't uncheck the "Sign the ClickOnce manifists" Checkbox in the Signing tab. From what I've found a certifate expired, but how is that possible if I create a new Solution?
Thanks in advance
Matthias
This seem to be a bug with visual studio. I had the issue with Visual Studio Premium 2013 update 2. But with Update 3 (12.0.30723.00), the issue is gone.

Visual studio cannot start debugging because the debug target is missing [duplicate]

When I try to build my solution, I get the following error:
Visual Studio cannot start debugging because the debug target 'c:\target' is missing. Please >build the project and retry, or set the OutputPath and AssemblyName properties appropriately >to point at the correct location for the target assembly.
My output path is set correctly to bin\Debug, but the exe is never created in that folder. Instead, all I get are the exe.config, vshost.exe, and vshost.exe.config files.
Any idea what's going on?
Make sure that output path of project is correct (Project > Properties > Build > Output path)
Go in menu to Build > Configuration Manager, and check if your main/entry project has checked Build. If not, check it.
Go to properties > Application , and select the output type of your project
I've had the same problem;
Here are solutions that didn't work for me:
Building/rebuilding entire solution
Making sure the output path was correct (MyProject > Properties > Build > Output > Output path)
Here's the solution that did work for me:
Rebuilding just the project
You could open the project file with a text editor and replace 'c:\target' by 'bin\Debug'
EDIT
There are other more helpful answers but I can't delete mine since it's the accepted one.
#CZFox Answer
#Yehuda Shapira Answer
steps for changing target path is
Go to Properties
Then go to Debug
Browse the Start external program and select the bin/Debug/.exe file
I have solve this type of problem follow this step
1.VS2010 right click on the solution explorer and select the Build.
Again press Ctrl+F5 or F5
You can try the following steps to resolve the problem.
Step 1:
Right click on the solution and select the property
Step 2:
In Configureation property select the Build option button
I just stumbled across this problem, but I'm using Visual Web Developer Express 2010 and couldn't find any wrong path either within IDE or in the project file. Rebuilding or deleting build folders didn't help.
But after examining the projects .user file, which I've never done before, I discovered that the bad path was in there. Very simple if one knows where to look.
I had the same problem and the real solution was embarrassingly easy:
If, in your project, Visual Studio has never successfully compiled the program (before finding the first bug), you will get this error. What I did was remove all offending code (in my case, leaving just a simple button1_Click with no code). Run/Compile the code one time; exit the running program, and this message goes away.
The Compiler builds various directories and files on a first successful compile and these are used by the debugger. I am now recommending with all new projects, define the form, compile, close, and then begin coding.
I've found that this can happen if all the files are deleted from the bin folder. ReBuild the app to force a full build: right click on the project in solution explorer and select ReBuild.
Please follow the below steps to overcome this problem:
If you are working with VS2010, change platform target to x64
Select .net framework as 3.5
If you are using any custom code for Sharepoint and like to debug or deploy the use the above....and my bad sake i dont abt the .net applications
I had this error too (in VS2010), and in my case (two projects in one solution, with one being for unit tests) the answer was to go into the solution's (not the project's) properties and set a single startup project. I would've thought it also necessary, in that project's settings, under Application, to specify the "Startup Object", but it's working for me with or without that.
Although this has already been answered, I found that my own solution was none of the above. Admittedly a rookie mistake, within my solution I had multiple projects, and thus when trying to run solution, the wrong project was set as the Startup Project.
So in my own case, not to say others, the solution was to right click the project and select Set as Startup Project
I tried everything mentioned in this thread but none worked.
Then, i tried the simplest thing and it worked.
Close visual studio and open it back up again.
This was a really annoying error!
I kept trying to start a debug instance but it just wouldn't make an exe! Though there were errors in my ConnectionString (while trying to make an SQL connection). There were two backslashes that were supposed to be a part of a path and the tutorial I was following told me to ignore it.
Well, turns out that was the error. A backslash marks the beginning of some escaping that you want to do, and the way to have a backslash displayed is \\ instead of \.
Got rid of that, and it worked for me.
EDIT: It would seem that you have to get rid of the tiny errors that you have made while writing your code to let it compile properly.
I have solved this problem by changing the Platform Target to "any CPU".
If the above explanation does not help you, then you could have error in the program. I have the same issue and I solved it as I cut the functions used in the same class and one of the functions were the cause of it.
I had a very very similar problem, but almost non of the solutions worked for me, finally when i reset the VS setting, it fixed...
To reset settings:
Tools Menu >
Import and Export Settings >
Select Reset all settings radio >
Next >
Next (You can backup your current settings in this step) >
Finish
Problem:
The problem was I had bad nuget source configuration, so the solution could not start properly despite the fact it was build correctly because it still saw old dll references.
Solution:
It was not enough to change nugget source url, I just had to remove entire nugget source and add it again with proper url.
Clean solution and rebuild it.
There are many issues that can lead to this problem, after losing 2 days to this issue I think I have the root cause of this issue and also the problem of the Form Designer throwing an error when switching to the Design view (also seems to effect the DataSet Designer):
A language syntax error that Intellisense doesn't catch.
Once I went through my code with a fine tooth comb I found a couple of really boneheaded mistakes that I kept overlooking, once those were resolved the solution compiled just fine and the output was in the correct place.
Here is the solution for this problem, no need to change anything for this problem.
You all know C# is case sensitive language and we have to write all methods and statements in correct case.
We all are just missing this thing and we just have to change method 'main() --> Main()'
This thing solved my problem please let me know if you still find any :-)

Installing windows service fails: service already exists

I'm trying to reinstall a service I've written using C#.
The first time this worked. I used installutil to handle the install and the service showed up in the list of services and I could start it.
Then I made some updates to the code and uninstalled the service. After figuring out I had to close the services window, the service seemed to have disappeared (i.e. successfully uninstalled).
However, upon trying to install the service again I got the message saying:
System.ComponentModel.Win32Exception: The specified service already exists
This seemed strange as I couldn't see it in the services window. I finally thought I found the problem after deleting a registry key regarding my service, but unfortunately this didn't solve anything.
Also, uninstalling again doesn't do much to solve the problem as this results in the contradictory message:
System.ComponentModel.Win32Exception: The specified service does not exist as an installed service
What should I believe? Does or doesn't the service exists? I feel like a physicist trying to figure out whether the cat is dead or alive. I hope someone here knows something to help solve this problem.
A related SO-answer finally pointed me in the right direction (why I didn't find that in Google or SO's own search I don't know).
Anyway, apparently the Designer.cs generated by Visual Studio also creates a process- and service-installer. Which of course install services with the same name as my manually created installers.
Removing my own installers solved the problem.
Actual issue is that you have added the object of serviceProcessInstaller & serviceInstaller multiple times in your code ..
It should only be added once..
Open the designer.cs file of projectinstaller you will see it is already added there...
I was also getting the same error, so to resolve, what I did was:
Open the ProjectInstaller.cs from solution Explorer
Go into view designer mode by right clicking, if code view is there
You will see a new installer apart from defaults 2, i.e. serviceprocessInstaller1 and ServiceInstaller1.
Just remove that installer which was automatically generated. Now build and install, it will work.
Check the Service Name Property in Service Installer.
I have tried all solution mentioned above. But my service was installed with some different name in registry. So just try to delete that registry.
Open below link in registry
Hkey_Local_Macine>System>CurrentControlSet>Service>
But I didnt find my service under this path. So I tried to find it out in registry. Just press ctrl + F and give the name of your service. or some guess name. You will get the exact location.
Just delete it. It will work.
Need to remove "Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.ServiceInstaller1, Me.ServiceProcessInstaller1})" line if same line is there already in designer, then it will get installed.
ServiceProcessInstaller1 is name in my project.

Debug Target Is Missing?

When I try to build my solution, I get the following error:
Visual Studio cannot start debugging because the debug target 'c:\target' is missing. Please >build the project and retry, or set the OutputPath and AssemblyName properties appropriately >to point at the correct location for the target assembly.
My output path is set correctly to bin\Debug, but the exe is never created in that folder. Instead, all I get are the exe.config, vshost.exe, and vshost.exe.config files.
Any idea what's going on?
Make sure that output path of project is correct (Project > Properties > Build > Output path)
Go in menu to Build > Configuration Manager, and check if your main/entry project has checked Build. If not, check it.
Go to properties > Application , and select the output type of your project
I've had the same problem;
Here are solutions that didn't work for me:
Building/rebuilding entire solution
Making sure the output path was correct (MyProject > Properties > Build > Output > Output path)
Here's the solution that did work for me:
Rebuilding just the project
You could open the project file with a text editor and replace 'c:\target' by 'bin\Debug'
EDIT
There are other more helpful answers but I can't delete mine since it's the accepted one.
#CZFox Answer
#Yehuda Shapira Answer
steps for changing target path is
Go to Properties
Then go to Debug
Browse the Start external program and select the bin/Debug/.exe file
I have solve this type of problem follow this step
1.VS2010 right click on the solution explorer and select the Build.
Again press Ctrl+F5 or F5
You can try the following steps to resolve the problem.
Step 1:
Right click on the solution and select the property
Step 2:
In Configureation property select the Build option button
I just stumbled across this problem, but I'm using Visual Web Developer Express 2010 and couldn't find any wrong path either within IDE or in the project file. Rebuilding or deleting build folders didn't help.
But after examining the projects .user file, which I've never done before, I discovered that the bad path was in there. Very simple if one knows where to look.
I had the same problem and the real solution was embarrassingly easy:
If, in your project, Visual Studio has never successfully compiled the program (before finding the first bug), you will get this error. What I did was remove all offending code (in my case, leaving just a simple button1_Click with no code). Run/Compile the code one time; exit the running program, and this message goes away.
The Compiler builds various directories and files on a first successful compile and these are used by the debugger. I am now recommending with all new projects, define the form, compile, close, and then begin coding.
I've found that this can happen if all the files are deleted from the bin folder. ReBuild the app to force a full build: right click on the project in solution explorer and select ReBuild.
Please follow the below steps to overcome this problem:
If you are working with VS2010, change platform target to x64
Select .net framework as 3.5
If you are using any custom code for Sharepoint and like to debug or deploy the use the above....and my bad sake i dont abt the .net applications
I had this error too (in VS2010), and in my case (two projects in one solution, with one being for unit tests) the answer was to go into the solution's (not the project's) properties and set a single startup project. I would've thought it also necessary, in that project's settings, under Application, to specify the "Startup Object", but it's working for me with or without that.
Although this has already been answered, I found that my own solution was none of the above. Admittedly a rookie mistake, within my solution I had multiple projects, and thus when trying to run solution, the wrong project was set as the Startup Project.
So in my own case, not to say others, the solution was to right click the project and select Set as Startup Project
I tried everything mentioned in this thread but none worked.
Then, i tried the simplest thing and it worked.
Close visual studio and open it back up again.
This was a really annoying error!
I kept trying to start a debug instance but it just wouldn't make an exe! Though there were errors in my ConnectionString (while trying to make an SQL connection). There were two backslashes that were supposed to be a part of a path and the tutorial I was following told me to ignore it.
Well, turns out that was the error. A backslash marks the beginning of some escaping that you want to do, and the way to have a backslash displayed is \\ instead of \.
Got rid of that, and it worked for me.
EDIT: It would seem that you have to get rid of the tiny errors that you have made while writing your code to let it compile properly.
I have solved this problem by changing the Platform Target to "any CPU".
If the above explanation does not help you, then you could have error in the program. I have the same issue and I solved it as I cut the functions used in the same class and one of the functions were the cause of it.
I had a very very similar problem, but almost non of the solutions worked for me, finally when i reset the VS setting, it fixed...
To reset settings:
Tools Menu >
Import and Export Settings >
Select Reset all settings radio >
Next >
Next (You can backup your current settings in this step) >
Finish
Problem:
The problem was I had bad nuget source configuration, so the solution could not start properly despite the fact it was build correctly because it still saw old dll references.
Solution:
It was not enough to change nugget source url, I just had to remove entire nugget source and add it again with proper url.
Clean solution and rebuild it.
There are many issues that can lead to this problem, after losing 2 days to this issue I think I have the root cause of this issue and also the problem of the Form Designer throwing an error when switching to the Design view (also seems to effect the DataSet Designer):
A language syntax error that Intellisense doesn't catch.
Once I went through my code with a fine tooth comb I found a couple of really boneheaded mistakes that I kept overlooking, once those were resolved the solution compiled just fine and the output was in the correct place.
Here is the solution for this problem, no need to change anything for this problem.
You all know C# is case sensitive language and we have to write all methods and statements in correct case.
We all are just missing this thing and we just have to change method 'main() --> Main()'
This thing solved my problem please let me know if you still find any :-)

section registered as allowDefinition='MachineToApplication' beyond application level

I am getting this error when I create a new folder, and upload files to it. I have an existing site that's built, but I don't want to add this to the site, but rather have it be an application all by itself. Any ideas?
This is indeed the first scenario to check. However, the most frustrating scenario in which this error occurs is after a build/publish under a different build configuration (i.e. build under Release, and then trying to build under Debug and getting this error). You should perform Clean operation on the Release mode.
See this answer which points to further details: Error: allowDefinition='MachineToApplication' beyond application level
I just had this problem not too long ago. Go into IIS, select the folder you created and go to properties. You will see "application name" greyed out, click the "create" button and save it. You will be able to run your separate application in it.
I just solved such errors after hours of trying, I had the same scenario resolved by simply deleting any back up files your solution may have created moving your application from one version of visual studio to the other and the problem is resolved
I faced this issue many times. Different solutions worked in different occasions. Following are the solutions.
Create an IIS application for your web site.
Clean the solution and rebuilt again.
Delete the obj folder and rebuilt again.
Open IIS click right click on the folder and Click "Convert to Application"
well i've just resolved this error.
just go to your project/website folder (not the published one). search web.config in the whole folder if it found more than once, you know which to delete. otherwise if only one web.config is found. make sure its has the rights to be Read. and the final problem if everything is fine, then make a new project in visual studio and remove all the components then add existing project by right clicking it, build,debug. Voila!!!
I had this problem when I moved my application from Window XP to Windows 7. The error is primarily because you did not convert your folder into Application.
The mistake that I was making was, when I selected the folder in IIS and right clicked, I choose "Add Application". This should be "Convert to Application". The resolved my problem.
You want to remove the application from your folder then do the process again and select "Convert to Application".
The project folder you are accessing might be the incorrect one Which result in finding two webconfig file for a project. So try to open the correct website.
For what it's worth, while in development, I got this same error when using "Open Website" on a project that I created using "New Project". If I instead open with "Open Project", the error goes away.
I just faced this today...Here is my fix and understanding of it.
Right click on your webproject and 'unload' it.
Edit your projects .csproj file (I assume .vs.proj in vb)
Look for 'true'
Change it to false.
Save your .csproj
Right Click on the .csproj and reload it.
Hopefully fixes your problem.
It's my understanding that the error you are getting is 'real', in my case
in my web.config was causing the error, because this should actually be set on our server, not by the application.
For some reason, reading Phil Haacks post help me to figure this out...I hope this helps others, I was unable to find a solution that met our needs while looking.
If you are getting this error in Visual Studio, Scott Michell has explained it very well.
Basically you are opening the parent folder of the site. In this case web.conf is in subfolder which does not allow certain tags and hence this error. To resolve, simply reopen the site and select the root folder. The error should disappear.
If the error is IIS related, then creating Application for the folder might help.
Open IIS
Select the Application Pool
3.Select pool where application hosted
4.Click on "Advanced Settings"
5.Change the "Managed Pipe Line Mode" to "Integrated"
If your web application is running in the SharePoint hive, remember to copy your application to the correct hive (14 or 15) and server (FE or App) and then create the virtual directory in the SharePoint 80 "_layouts" subfolder.

Categories

Resources