Reputation: 335
I have a VS2013 C# .net 4.0 solution and one of the C# projects (console application ) has a folder called "Service References". In the folder, there are two subfolders
One is : MyReference1, it has files of
configuration.svcinfo
configuration91.svcinfo
MyApplication1.disco (web service Discovery File)
MyApplication2.wsdl (web service description language)
Reference.cs (Visual C# source file)
Reference.svcmap
Another one is: MyReference2, it has files of
configuration.svcinfo
configuration91.svcinfo
MyApplication3.wsdl
MyApplication4.disco
MyApplication4_1.xsd
MyApplication4_2.xsd
MyApplication4_3.xsd
MyProject.MyReference.JobStatus.datasource (visual studio data source file)
Reference.cs
Reference.svcmap
Now, for some reasons, I have to create a new project in a new solution (of VS2013 C# .net 4.0) with exactly same services references as the above one.
After creating a new solution and a new project (which has same property as the above one), I tried to add the above existing files in the above subfolders into my new project. I created a new folder called "Service References" and the subfolders with the same name as above. But, when I build the project, I got the errors, for example,
In Reference.svcmap:
Error 1 Custom tool error: Failed to generate file: The system cannot find the file specified. (Exception from HRESULT: 0x80070002) C:\MyPATH\MyProject\serviceReference\MyReference2\Reference.svcmap
In Reference.cs
Error 5 The type or namespace name 'ServiceModel' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\MyPATH\MyProject\serviceReference\MyReference1\Reference.cs (the file was auto-generated by a tool )
The difference between the folder "Service References" in my project and in the old project is that thee are only two subfolder names under "Service References" in the old project and no files inside the folder are shown in the project. But, in my project, all files are shown because I added them as existing items.
When I right clicked the project and add service reference by pasting the path (where the "Service References" is located) in the "Address" part, I got error:
There was an error downloading 'C:\MyPath\Service References'.
Access to the path 'C:\djx_2014_6_3\MyPath\Service References' is denied.
If the service is defined in the current solution, try building the solution and adding the service reference again.
I run the VS2013 as administrator.
How to add service references correctly?
Upvotes: 2
Views: 9438
Reputation: 489
Don't add this folders to the project as files.
You have to right-click on project -> Add... -> Service reference and then paste path to wsdl file. Do this for each service.
Also if your both projects are in one solution, you can just add a reference to project containing this services and generated code will be shared between projects. Right click on project -> Add... -> Reference -> Solution and check project containing services.
Upvotes: 2