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

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.

Related

Cannot fetch wcf service remotely

i have 2 systems, one is localhost(Windows 8.1Pro) and another is Virtual Machine(Windows server 2008R2).
i have a silverlight app hosted in VM which is consuming WCF service from localhost installed in windows service.
Problem:
silverlight is not getting clientaccesspolicy.xml and crossdomain.xml so wcf service will not fetched.
Tried solutions:
Added clientaccesspolicy.xml and crossdomain.xml in WCF service solution before installing but still it can't be fetched from WCFservice url.
Added clientaccesspolicy.xml and crossdomain.xml in C:\inetpub\wwwroot folder, as per my search so many suggested to place their which will be automatically fetched by silverlight.
tried adding clientaccesspolicy.xml code into wcf service as per this link still no success.
Any suggestions will be appreciated.
Edit:
okay i am attaching code FYR, i am doing this as below.
once i build WCFTest , 'll get .exe wcf installer which i am installing that using installutil.exe, so service'll be up and running in services.msc.
once i build TestSL, 'll get TestSLTestPage.html , on double clicking on this it'll open in IE, and on button click i should get "Hello World" from WCF.
Download it from here and suggest me if i am doing anything wrong. Attached projects are of exact same structure as i am workinig on....
Regards,
Jithendra
as i explained my prob.above i was using self hosted Wcf service and i couldn't solve the problem so Here's what i did
1. Created Default WCF Service application in VS2013 with all my code and added clientaccesspolicy.xml and crossdomain.xml in the solution.
2. Created a new website in IIS Manager to publish my project.
3. and published my project to IIS as filesystem.
4. There we'll have all the files that are necessary.
And Voila everything works perfect.
Hope it helps somebody.

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

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.

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?

Deploy WCF REST 4.0 to XP IIS 5?

I am trying to deploy a simple "Hello World" .NET 4.0 REST-style WCF service on WinXP (IIS5). It works fine in Cassini.
I tried to adapt the info here to me:
http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
but something is not clicking. Can anyone lend ideas or comments? Yes, I must stay with WinXP.
Thanks.
After a fair amount of struggling I was able to successfully deploy a WCF 4.0 REST web service on XP/IIS5. For the benefit of you and others in the same situation, here's what I did (let me know if you need more detail):
Using VS 2010, build a deployment
package for the project and then
install it on the target machine
(your web server). The following
link will show you how to do this: http://vishaljoshi.blogspot.com/2009/03/web-packaging-installing-web-packages.html
Make sure that your virtual directory in IIS is configured to use .NET 4 (right click on virtual directory > properties > ASP.NET tab > ASP.NET Version)
Configure your virtual directory to support extensionless requests (i.e. your REST API) by creating a wildcard mapping (right click on virtual directory > properties > configuration > mappings tab) with the following properties:
Executable: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
Extension: .*
Check that file exists: unchecked
(Note: watch out for the bug that keeps the "OK" button on this dialog grayed out. To get around this just click in the executable textbox after entering your extension and the "OK" button should get enabled).
If you get an authentication error when accessing the service then turn off integrated authentication on the virtual directory. This should fix the problem if you have used the defaults in the generated web.config of your service. If you have explicitly modified the authentication mode then you will have to adapt accordingly.
Have you considered self-hosting your service instead of trying to use IIS. That will probably be easier to do than use IIS.
In case above steps dont work. There could be a problem with permissions on your App pool for that website / virtual directory , you can try to set that right and try it out.
You can refer this article for more help on this.
http://technicalwizardry.blogspot.in/2013/04/wcf-rest-service-hosted-on-iis-5.html#!/2013/04/wcf-rest-service-hosted-on-iis-5.html

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.