Silverlight enabled WCF service port suddenly changed
I have a Silverlight web app solution with a Silverlight-enabled WCF s开发者_运维知识库ervice included. Everything has worked fine for the past 6 months or so. I can access data through the service with no problem.
I came into work today, opened up the solution, ran it again, and suddenly, there's a mismatch between the WCF service port and the port that Silverlight wants to use to access the service.
How and why would the port suddenly change?
How do you specify a port to use? I never specified a port in the past--it just worked. I can't find a port specification in the web.config or the service CS file.
Sounds like you are talking about a solution inside visual studio, you can view the default port by clicking Web project property, go to the Web tab, inside the "Servers" section you will see the default port number, you manually assign a specific port or use auto-assign port.
I have seen similar situation before, it happened when the port is being used. You can reassign the port by changing the port number in project property, recompile web solution then update the web service reference in your client project. Hope it helps.
Are you using the built-in Cassini web server? And is the WCF web service a part of the same web project as your hosting page? Or is it a separate project?
If you're using Cassini, the port at which it listens in a dev environment is specified in the project properties page, on the "Web" tab. Normally Visual Studio auto-assigns a port, but if you're using this as your web service, you'll want to tell it which specific port to use (e.g., 51000 or something). It might always have defaulted to the same port, but if it detects that this port is in use (perhaps by another Cassini instance on your machine that never exited), it would switch ports.
You should also check the ServiceReferences.ClientConfig file in your Silverlight project to see what port it's trying to connect to.
Is the WCF service hosted in IIS ? Has someone changed some IIS configuration?
When hosting in IIS, the IIS server name, port, virtual directory and name and location of the *.svc file define your service address on the server side. If any of those changes --> your service won't be available anymore.
You might have some other software that started using the port (Skype has caught me out in the past)
精彩评论