Related
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 .
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 :-)
I am trying to add a service reference to my website. When I add the service reference to a WPF application I get a reference.cs file that I can edit and add attributes to. When I try to do the same thing in a asp.net website there this file isn't present. I have also tried looking on the file system and the reference.cs isn't present. Can anyone provide some guidance?
EDIT:: Im using VS2010 and I need to edit the reference.cs to add [Webget] and [WebPost] attributes
If you want to manually edit a service stub, consider using svcutil.exe.
In Visual Studio, right-click on the reference under the "Service Reference" section of the Solution Explorer and click "View in Object Browser". Then, in the Object Browser, under the namespace for the reference, right-click on any of the properties and select "Go to Definition". This will load up "Reference.cs" file.
Hope this helps!
Edit:
Also worth noting is that the classes generated for you are partial classes, so it may be beneficial to consider extending them in a separate file so that you can still "Update" the reference and not have the generated code overwrite any changes you make. This would all depend on what you're planing on modifying though.
Depending on the version of VS it will create a folder under the project root. In my case under VS2010 I added a ref to http://www.webservicex.net/stockquote.asmx?WSDL, set the namespace to ServiceReference1 and it created a folder in the project root called \Service References\ServiceReference1 under which it stored all the ref files including Reference.cs
If you are not seeing this folder then there may be something wrong at your service that VS is unable to query the WSDL and generate the files. Try the stock service above to test.
And editing the generated files is usually a bad idea as they can get regenerated when you refresh the reference. Unless you want to rip the generated code out and never refresh it again.
UPDATE:
Seems like that webservicex service is slow, try this
Also, seems like there is a diff between "Web Reference" and "Service Reference". See here. But ultimately it creates a sub folder in your project root called either "Service References" or "Web References" with the sub folder of whatever you named your reference.
I'm going insane, I beleive.
That is, I've never had an issue like this before, and nobody (that Google has indexed) seems to be having the same issue.
Whenever I add a reference to a particular ASMX service to a VS2010 project, all of the code is generated, there is an interface ServiceSoap that represents all of the features of the service, but there is no concrete implementation of that interface anywhere in the solution!
What am I doing wrong? I just right click project, add service reference, paste url to .asmx, type 'Blah' in the namespace box, click OK.
Everything seems to happen OK. I'm just bat-shit insane, I guess...
Update:
If I go to Advanced... in the add service reference dialog, and choose to add it as a .NET 2.0 service, everything works, but I don't particularly want to do it that way.
The actual namespace I'm using is Remedy and the service .asmx file is Service.asmx.
Try this...
right click on the service reference. then go to configure service reference. then uncheck reuse types in referenced assemblies checkbox.
upd
this solved mine, hope it will help somebody else too
Try these steps:
Look in the Output window to see if there are any errors when you use the "Add Service Reference".
Look in the Reference.cs to see if there are any errors (generated as comments).
Finally, try using svcutil.exe to generate the proxies, since it will be easier to see error messages.
Have you tried clicking "Show all files"?
With this feature on, the Service Reference can be expanded to its various "source" files.
While clicking "show all files" icon. There is another folder which they hold the same name. while deleting the folder. and clean the solution. Add new services with the same name.
Now its working fine.
Right click on the reference, then - "View in Object Browser" Just double click on one of the methods/properties inside the object explorer.
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 :-)