Search code examples
c#visual-studiosilverlightweb-servicesservice-reference

WebService won't update through ServiceReference


I have two projects in my Visual Studio solution: The one is a WcfService Application project and the other one is an ordinary C# Silverlight project with a ServiceReference to access the Web Service locally.

Basically everything works fine except the fact that changes in my Web Service are not visible in my SL project:

If i for example modify some attribute in a [DataContract] class of the service' interface, both projects compile well but the when accessing the web service in the SL project i only have the state before the modification.

Viewing the ServiceReference in the VisualStudios ObjectBrowser gives me the same result: My Web Service without modification.

I added the ServiceReference to the SL project via the in-built automatic "Add Service Reference" function. Everytime i modify the web service i click "Update Service Reference" on the Service Reference in the SL project which succeeds but without effect. Even a removal of the Service Reference and adding it again doesn't show me the web service with the altered attribute.

Maybe it's because i renamed the Service Project a few days ago - I unloaded the service project from the solution, renamed the folders in the file system and added it again as an "existing project" to the solution. Then i renamed the service file (.svc & .svc.cs) and the service interface file. ==> After that everything seems to work still fine except my unrecognized modifications ?! Also when adding a ServiceReference to this service I see the old names of the two files i renamed not the new ones !?

Does anyone has a clue what's going on here ? Thank you in advance for reading this long question ;)


Solution

  • One way to solve your problem (OK, it's probably not the best solution, even probably the worst one, but I'm sure it'll work) is to do a bunch of cleanup:

    • remove from your SL project your service reference
    • delete on your file system everything related to the service reference you deleted (i.e. drop related files/folders in SL project directory)
    • also open your SL csproj (or vbproj) file with notepad and delete the lines that are related to service references (search for "Service References" in the file)
    • create a new WcfService Application project from scratch, and add what's needed to it (references, files...) so it reflects the current WcfService project you have
    • delete the old WcfService project
    • compile your new WcfService project
    • add your new WcfService project as a service reference into your SL project

    Okay, you'll lose some time doing this, but it'll work.