Update service reference not working

2019-04-20 06:54发布

I'm using Visual Studio 2008 and have a WCF client working against a WCF service. They are both located in the same Visual Studio solution. After I've made a change in my WCF contract, I want to update the service reference on the client so that changes made to the contract is also made in the proxy.

My problem is that the proxy code is not re-generated.

When I select to update the service reference, the following happens:

  1. A dialog with the title "Updating service reference 'name-of-reference'" is shown. This dialog has a progress bar.
  2. The progressbar moves and the status text in the dialog is changed to "Updating configuration"
  3. The progressbar moves a bit more, and the status text is chnaged to "Configuration update complete"

The dialog doesn't show the text "Generating \something\" (can't remember the exact wording) which I would expedct.

If I delete the service reference and add it again, the proxy is properly generated. I add the service using the exact same settings as before, so I don't think it's a issue I can solve by changing the service reference configuration on the client.

One thing I suspect may be the problem is that I've renamed the default wsHttpBindings in app.config. I've also renamed the default endpoints. The reason behind this is that I need more than one endpoint and having one named 'some-default-name' and one with my own name is just confusing.

The problem with deleting the service and adding it again is that Visual Studio adds a new binding in app.config (among other things) which should not be there.

Anyone seen this problem before? Anyone knows of a solution to it?

12条回答
趁早两清
2楼-- · 2019-04-20 07:24

Two easy steps to solve that:

  1. Run Service, then stop it.

  2. Update service reference.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-04-20 07:32

Highlight the service as the active project, F5 to run it in VisualStudio, it will start up in the service test app. Stop debugging. Then try to update your service reference - worked for me.

查看更多
Summer. ? 凉城
4楼-- · 2019-04-20 07:34

I had this problem too. Deleted the service reference and recreated it again.

查看更多
神经病院院长
5楼-- · 2019-04-20 07:35

I had the same problem, this by me it was caused by GIT Merge Conflict, i was missing the following code from my csproj file

   <ItemGroup>
    <None Include="Service References\<SERVICE NAME>\Reference.svcmap">
      <Generator>WCF Proxy Generator</Generator>
      <LastGenOutput>Reference.cs</LastGenOutput>
    </None>
  </ItemGroup>

I have added this onder the line of Reference.svcmap

查看更多
对你真心纯属浪费
6楼-- · 2019-04-20 07:36

When we have had this problem it has usually been one of these errors:

  • The size of the contract has increased, and is now so large that the WCF configuration does not allow it to be transferred.
  • A new class has been added to a WCF Interface and that class is not marked as serializable.
  • There is a compile error that stops the code from building and it therefore uses the old dll
查看更多
Bombasti
7楼-- · 2019-04-20 07:41

In my case the problem was that the previous developer had added the service reference using his machine name rather than localhost. So when I told Visual Studio to update, it connected to his machine, which did not have the changes. I modified the service reference files and replaced his machine name with localhost and it was able to update the reference.

查看更多
登录 后发表回答