Update service reference not working

ぐ巨炮叔叔 提交于 2019-12-05 00:07:14

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

I've run into this problem with the following conditions:

  1. Our workstations are connected to an Active Directory domain (nearly everything uses Windows Authentication)
  2. The service reference I'm trying to update is hosted on localhost, and is running under IIS Express (so the Application Pool user is running as the developer's personal domain user account)
  3. Another developer has added or updated the reference to the project more recently than me.

The only way I have figured out how to workaround this issue is to edit the configuration.svcinfo file for that service reference (you will need to show all files for the project to see it in visual studio), locate the following section:

userPrincipalName value="user@domain.com"

and change the user to my own domain user. After saving the file, I have no trouble updating the reference until another developer updates the service reference (likely using the same workaround). Unfortunately, I haven't been able to figure out a permanent solution to this issue.

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.

My error was that I forgot to add the OperationContract attribute.

My problem was that I had two methods with the same name. Everything builded fine, but I couldn't update service reference. When I tried to start just the WCF service, the error pops up.

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.

Two easy steps to solve that:

  1. Run Service, then stop it.

  2. Update service reference.

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

I know this solution is a bit late, but after trying the posted solutions with no success, this worked:

When you create a WebService, it generates a .dll file that you reference as your service reference. This .dll is (as most know) not recreated everytime you make changes to the .SVC file. You can see this if you go and view the date modified property of the web service .dll file, in my case it was three hours old!

My solution was to make appropriate changes to the service contact, save it, and re-build the project which will cause it to recreate all the .dll's reflecting the changes you made to the service contact file (.svc).

After this, update the service reference on the client app, and the changes are evident.

  • Spades

I had the same problem. Modified some of the data contracts. Tried to "Update Service Reference" and did not see the change. Dropped and re-added the service. Still didn't see the change when writing code in the client. Opened my client with Reflector and saw the service types had the change! So why was intellisense still showing old properties? Restarted Visual Studio and the modifications finally showed in intellisense.

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

Another solution to these kinds of problems is if your namespaces get jumbled in referenced projects that both consume the service. So:

ProjectA - Consumes ServiceA

ProjectB - Consumes ServiceA, Has Reference to ProjectA

If you change ServiceA and update ProjectB, sometimes the namespaces can can change to look at ProjectA's version of the service.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!