Updating Service reference WCF in VS2010 SP1 (mvc3 project) TFS -- Causes other developer failing to compile - wcf

On my local machine, I consume a WCF service via the Service References. I can add to the other WCF project and check in to TFS , run the service, Go to my main project and Click on Update Service Reference, and my web.config is fine whether change is needed or not. Rebuild is fine.
However, on another developer's machine, they make a change to the WCF Service run it, and go to main project and Update Service Reference, and sometimes the web.config get trampled, it doesn't show the Url to the wcf service etc... Thus compiling project causes a issue where it cannot find the namespace for the service reference.
Then if I get latest and checkin and tell a developer to get latest, their web.config will update, but they still increasingly have a problem with the namespace for the service reference does not exist. It is running, the update to the service works. The Url in the browser shows the endpoints.... but vs 2010 sp1 has repository files that cannot find the service reference for some reason. "Are you missing an assembly reference?" Any ideas??

If in the svcutil dialog, the option to use shared assemblies is turned on, and if any signed assemblies are not an exact match, the checked in version will fail on the other machine.
You need to make sure the assemblies used have the same public key token.

Related

Publish a WCFService doesn't work; Debugging-mode works

I want to start an default webservice-project, where I can send data over a service. When I go to debug the API through VS then everything works fine, but not when I try to use it over IIS.
I created an WcfServiceLibrary-Project in Visual Studio 2017. I then right-clicked on the project (in the solution explorer) and then published it to a folder A.
I also didn't do anything special at IIS (all the things are still on localhost.): I activated the default windows-feature "IIS". (The default web site got also stopped). Then I added there a site with an random name and the path to the folder A. The service got started.
My access trial was to find anything through Visual Studios "connected services".
Has anyone an idea?
At first, please use the WCF service application project template,
or the Appconfig file would not be kicked in. library project needs the additional configuration in the hosting environment, and the Appconfig file could not recognized. We have to move the configuration code into the configuration file recognized by your hosting environment.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/deploying-a-wcf-library-project
Secondly, for hosting the WCF service in IIS, we should enable the below windows feature.
Feel free to let me know if the problem still exists.

WCF service operations not updated

I´m creating a new WCF service. I initially had only three operations. But after some time I decided to add two more. This operations doesn't appear in the Microsoft test client, neither in the list of operations when I try to add a service reference from my WPF client. Also I tried to comment one of the initial operations. It still apears in the Microsoft test client and can be invoked. I Tried also delete the dlls generated by the service and regenerate again. No luck. There are some kind of "cache" where Visual Studio stores the WCF services libraries that I can delete?
UPDATE: I'm working with the service running in the ASP.NET devolopment server.
You need to understand the order in which things happen.
You change your code, adding methods with [OperationContract] on them, or removing them, or changing their parameters or return values.
You then must build your service, producing a .DLL that contains the changes.
You must then deploy the changed DLL to the server it's going to run on
You must then restart the service (this may happen automatically depending on the server. For instance, IIS will recycle the service when it sees that the DLL changed)
You must then update your client, either the WCF Test Client, or "Add Service Reference", or the equivalent.
This last will have the effect of sending a request to the service for the new metadata or WSDL. Only then can the client see the changes you made to the definition of the service.
I don't know why, but I created a new project and copied the definitions of the operations from the problematic project and the problem is gone. One case more for Microsoft mysteries.
Make sure you are updating the services after adding the new operations.
Also make sure they have the attribute [OperationContract].
One thing we have discovered is that when you deploy the dlls that they must be in the bin, and cannot reside in the debug or release folder.
For me worked: just rebuild the wcf project
Did you close the client connection in client side
as showing your service
class Test
{
static void Main()
{
LocationClient client = new LocationClient();
// Use the 'client' variable to call operations on the service.
// Always close the client.
client.Close();
}
}
SOLUTION HERE :
Make sure your dataContract does NOT contain any enum
(You can use integer instead)
Be sure to reference a project in the solution and not a dll on your disk
Remove your "bin" and "obj" folders
Recompile
In IIS recycle the application pool
In IIS restart your service
In IIS "Browse" your service
=> You got it

WCF Service Reference issue on production in console application

I have 1 c# Console Application project, which has Program.cs (that contains main method), the main method simple calls a web service method and displays the string on the console.
The service reference is added in the project by right clicking it and adding service reference it to it.
when the console application is executed in debug mode from visual studio, it works as expected.
when the console application is executed from a .exe found in /bin/debug, it works as expected.
so far so good.
PROBLEM:
when the project is copied over to the system (you can call it a production environment), where this .exe will actually be executed, it fails at the exact line where i create the service proxy object. the line in Program.cs is:
ProjectName.ServiceReference.ServiceClient service = new ProjectName.ServiceReference.ServiceClient();
I know it fails here, because i have Console.Writeline("some line"); before and after the above line. I can see the Console.Writeline that is before the proxy line, and soon after that it crashes ...
I think this is because the reference paths that are referencing the service, is there any thing i can do to change the paths, or confirm that it is the path issue as suspected ...??
any idea whats going wrong ..???
Check this link: http://blog.davidsandor.com/post/Workaround-The-configuration-for-the-servicee280a6Unrecognized-element-e28098extendedProtectionPolicye28099.aspx
The configuration for the service reference could not be updated due
to the following issue: Unrecognized element
‘extendedProtectionPolicy’. (App.config / Web.config)
There does not seem to be a really clear reason why this is happening
however it seems to be related to Windows 7. I am not sure if the
.NET framework that ships with Win7 has some different setting or
template for the WCF configuration policy files but it seems to be the
culprit. Maybe the machine.config files are different on Win 7 and
the WCF configuration tools use the machine.config as some sort of
policy template.
The fix is annoying (because every time you build your solution on
Windows 7 and then rebuild on Vista you have to redo this).
Remove the line:
<extendedProtectionPolicy policyEnforcement="Never" />
from both your App/Web.config file on the client and on the WCF
server’s Web.config file.

Debug WCF service hosted in local IIS not working

I have one solution WCFSampleSolution and it has all my projects - Web Service, Client and Website. The structure is something like:
WCFSampleSolution
C:\WCFSample\Website
WCFService
WCFWebClient
I created WCFService project for my services. It contains IService1.cs and Service1.cs. Then I hosted the service in IIS. I did this by creating a website and adding .svc and web.config files to the website project. Then published it in IIS. When I run http:\MyMachineName\Website\Service.svc, it shows the service description. Then I create the web client that calls the webservice. I used the service reference to add the service. It calls a method of Service1. It works fine. But I amnot able to debug this program/setup. I verified the config files in WCFWebClient project and Website project and they have proper debug settings.
<compilation debug="true">
I put break points but control never goes to my seb service. I also tried attach process, but it also doesn't work. But I was able to debug one of my other WCF projects. The setup was little different. In that project I copied the .svc file and config in my web client and the debug works fine.
Please HELP!!
You are hosting your service on IIS so I am sure you must be attaching to w3wp.exe process. While trying to attach if VS built in web server is starting, then attach to that process as well.
What I find particularly easy is having two instances of visual studio open (especially if you use NUnit or doing anything to test out code). One will attach NUnit or whatever you wish, and the other will attach the w3wp.exe process. The easiest way is to:
1) Put a break point in the 1st instance of visual studio of the code right before it will hit the WCF service hosted on your machine.
2) Once the code stops at your breakpoint, set breakpoints in the 2nd instance of visual studio where you want to break then attach the w3wp.exe process.
3) Once you continue, the breakpoint on the service code should be hit.
It is sometimes easier to find the process id as well when attaching w3wp.exe. Using IIS, you can go to "Worker Process" and find the process id to attach for your Application Pool Name.
#user465876 - another approach that is less of a hassle can be found here: WCF can no longer step into a service that's locally hosted -- why not?

Update service reference not working

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:
A dialog with the title "Updating service reference 'name-of-reference'" is shown. This dialog has a progress bar.
The progressbar moves and the status text in the dialog is changed to "Updating configuration"
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?
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:
Our workstations are connected to an Active Directory domain (nearly everything uses Windows Authentication)
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)
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.
My error was that I forgot to add the OperationContract attribute.
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.
I had this problem too. Deleted the service reference and recreated it again.
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.
Two easy steps to solve that:
Run Service, then stop it.
Update service reference.
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.
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.