WCF service reference error
Last post 08-11-2008 8:50 AM by kbatyai. 7 replies.
Sort Posts:
08-08-2008 6:04 AM
WCF service reference error

Hi,

 

I 've started to develop a Silverlight app...

My steps:

  • New silverlight project (with file based test web project)
  • Add WCF service (silverlight enabled) to web project
  • Implement service
  • Add reference in Silverlight project to System.Data.Services.Client
  • Try to add service reference in the Silverlight project to the Service...
  • but...

When i press the discover button it founds the the service...(the ASP.NET development server starts...)

But...it found on a port that ALWAYS less then the real port by 2. Always 2.

So...

  • the Visual Studio always randomize a new port number, when I start, or i discover services ( when the ASP.Net dev server isnt running)
  • the Add Service Reference "wizard" founds the service, but it can't add it to the project
    (same errror when i manually change the url to the right port number
    error:

    There was an error downloading 'http://localhost:50906/SilverExamWeb/WCF/Common.svc'.
    The underlying connection was closed: An unexpected error occurred on a receive.
    Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
    An existing connection was forcibly closed by the remote host
    Metadata contains a reference that cannot be resolved: 'http://localhost:50906/SilverExamWeb/WCF/Common.svc'.
    An error occurred while receiving the HTTP response to http://localhost:50906/SilverExamWeb/WCF/Common.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
    The underlying connection was closed: An unexpected error occurred on a receive.
    Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
    An existing connection was forcibly closed by the remote host
    If the service is defined in the current solution, try building the solution and adding the service reference again.

  • When i paste the url to IE, it works, and i get the WSDL xml...
  • I tested it in a simple app in another VS, and i got the same error... when in IE works fine... too

So What is the problem?!?
What mistake do i?

And why VS randomize a port?!?

Thanks Kris

kbatyai

Loading...
Joined on 08-08-2008
Posts 8
08-08-2008 6:18 AM
Re: WCF service reference error

Please refer to this video...it would help you......

http://silverlight.net/learn/learnvideo.aspx?video=47177

Kindly mark as answer if it helps.

http://www.akstech.com/

jeetAbhi

Loading...
Joined on 06-18-2008
Mumbai, India
Posts 71
08-08-2008 7:31 AM
Re: WCF service reference error

 Thank's the link, i 've seen it. But...

I do the same, but it doesnt do the same :)

The VS randomizes the port, and if i overwrite it, it doesnt find the service, and show that error what i wrote...

My system:

-newly installed vista

-vista sp1

-vs 2008 prof edition

-vs2008 sp1 beta1

 

kbatyai

Loading...
Joined on 08-08-2008
Posts 8
08-08-2008 7:51 AM
Re: Re: WCF service reference error

If it is the problem with dynamic ports then try this...NOTE: im using VSTS 2008

Go to solution explorer ==> Click (no right click) on web application which gets created by silverlight app. ==> Press F4 in the keyboard.

A Dockpanel shows up you can set there properties such as , Always use dynamic ports and set ports.

If you are using other than VSTS 2008...i just right click on the web project and Properties. and there you can set port hopefully.

 

Thanks
Rajesh Shirpuram

(If this has answered your question, please click on "mark as answer" on this post. Thank you!)

rajesh shirpuram

Loading...
Joined on 08-13-2007
Pune,India
Posts 468
08-08-2008 8:26 AM
Re: Re: Re: WCF service reference error

 :)

Thanks I know what is the property page :)

 

The Silverlight project template creates a file-based web site, not a Web Project...
so, i cant turn off auto port :)

 -----

I think i will "change" the testing web site (file based) to Web Project and in that, i can set the port manually.....

 

kbatyai

Loading...
Joined on 08-08-2008
Posts 8
08-08-2008 8:41 AM
Re: Re: Re: Re: WCF service reference error

So... i made a test...

 i created a new silverlight app in VS, then a choosed WebSiteProject (not file based...) for test.
i added a silverlight enabled WCF service to the ASP.Net project and when i would like to add the service reference, i get the same error. (the port is fix and ok, because i set it manually.)

But the service reference wizard throw the same error ( the WSDL in IE works fine...)

 

I dont understand... VS bug? Vista bug? SP1 beta bug? or what...

kbatyai

Loading...
Joined on 08-08-2008
Posts 8
08-08-2008 8:55 AM
Re: Re: Re: Re: Re: WCF service reference error

 So... i made an another test :)

I add a WCF project to the solution and it works fine...

So if the WCF service in the ASP.Net project doesnt work, but why?!?

 Maybe configuration problems?!?

i tried with and without this :       <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

 

Any suggest?!?

kbatyai

Loading...
Joined on 08-08-2008
Posts 8
08-11-2008 8:50 AM
Marked as Answer
Re: Re: Re: Re: Re: WCF service reference error

So...

The solution is:

 

Use web project, so you can set the port manually...

and...

the Service Reference Wizard cant resolve the "localhost"...

after i commented out the   "::1             localhost" IPv6 section in the hosts file it has started to work :)

 

kbatyai

Loading...
Joined on 08-08-2008
Posts 8
Page view counter