0

I have a web app project and silverlight project in the solution. I have WCF file in web app, and I get the below error while updating the ServiceReference

There was an error downloading 'http://localhost:5678/DataForSilverlight.svc/_vti_bin/ListData.svc/$metadata'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://localhost:5678/DataForSilverlight.svc'.
The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.
If the service is defined in the current solution, try building the solution and adding the service reference again.

I also tried to Delete it and add it again, and I also tried deleting WCF file from web application.

T.S.
  • 18,195
  • 11
  • 58
  • 78
  • You may be have Silverlight project in the solution but not the service: http://localhost:5678/DataForSilverlight.svc. To add service, it has to be up and running – T.S. Jan 08 '14 at 21:13
  • i have added the DataForSilverlight.svc also. the previously it worked well, but after making some changes in the svc file iam unable to update,i have checked everything in the code of svc file and everything is fine,but it gives the above error – Genelia D'Souza Jan 08 '14 at 21:18
  • Remove service, do "clean project". Add it again. You have the port number that might change. – T.S. Jan 08 '14 at 21:20
  • double check you are still on port 5678. http://stackoverflow.com/questions/1576970/how-the-localhost-port-number-of-net-development-server-set – Joe Jan 08 '14 at 21:21
  • i have specific port number set to 5678 also cleaned the project and have built it again. – Genelia D'Souza Jan 08 '14 at 21:27

2 Answers2

0

This error usually happens when you're exposing the web application (and then your WCF service) through IIS, using a dynamic port, that changes every time you start and stop the debugging of the solution.

To avoid this problem, right click on the Web project and select 'Properties'. Select the tab 'Web'. In the groupbox named 'Servers', insert your desired network path and click the button 'Create Virtual Directory'. IIS will create a virtual directory for your web project.

enter image description here

Now you can add your service reference to the Silverlight project. The next time you execute the web project, the IIS will execute the web application using the desired network path.

Also, make sure that in the class definition of your service the following attributes are declared:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class DataForSilverlight

and that the following line is existing in your Web.Config file, in <system.serviceModel> section:

<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
Alberto Solano
  • 7,972
  • 3
  • 38
  • 61
  • @GeneliaD'Souza Please check also [this question](http://stackoverflow.com/questions/16240217/wcf-service-returning-404-on-method-reqests). – Alberto Solano Jan 08 '14 at 22:14
0

Dont know why but i again changed the variable type in the Method which was befor change is

[OperationContract]
        void SaveData(int UserId, string FileName, ExtendedImage File);

later changed it to string

[OperationContract]
        void SaveData(int UserId, string FileName, string File);

and everything works fine now

  • 1
    It seems very strange that a change like that is the responsible of a 404 error for the WCF service. As advice, to avoid misunderstandings, it's better to write a variable name that isn't also the name of a class. For example, it's better to replace the variable 'string File' in 'string file'. Anyway, you solved the issue. – Alberto Solano Jan 09 '14 at 08:51
  • i was passing an object which is of external library as a parameter to method in WCF :p ExtendedImage is the example above @AlbertoSolano – Genelia D'Souza Jan 10 '14 at 09:11