I've been trying to figure out how Silverlight communicates with a WCF Web service when the VS2010 Silverlight solution is set up as an ASP.NET Web Application Project rather than an ASP.NET Web Site. As you know, when you set up a Web Application Project, the Web service is generated as a .dll assembly rather than a set of loose .cs files that are supposed to be compiled once, when the Website is first accessed. But when the solution is set up as a Web Application Project, the service is encapsulated in a dll assembly. In my case, the service is in a DLL called PPTWebsite.Web.dll. When I build the solution, the Silverlight application is also wrapped in a xap file called PPTWebsite.xap and from what I've read, the xap file and the WCF Web service assembly have to be in the same folder on the Website, and further, the xap file has to be in the ClientBin folder off the root of the Website, so that's also where the PPTWebsite.Web.dll file must be located. (I've tried putting the xap file in the root of the Website and that doesn't work at all.) When I build my solution, a .svc file also gets created that identifies the location of the C# source file containing my Web service. This .svc file must be in the root of the Website and contains the following line: Code: <%@ ServiceHost Language="C#" Debug="true" Service="PPTWebsite.Web.PHDWebsiteService" CodeBehind="~/ClientBin/PHDWebsiteService.svc.cs" > What confuses me is that the value of CodeBehind points to the C# source file containing the source of my service implementation but doesn't identify the assembly containing its CIL code. So: how does the Silverlight application know where the code for the Web service is stored when it makes calls to it? I should also make clear that I have no problem communicating with the Web service when I execute everything from within VS2010. Everything is working perfectly when executed within the IDE. The reason this is an issue is because when I deploy everything to the actual Website, the Silverlight application is not communicating with the Web service. I know this is true because I stripped down one of the services to a one line function that simply returns true and when the Silverlight event handler gets control it immediately throws an exception with the text, "The remote server returned an error: NotFound." (Google for that text and you will get thousands of hits on forums like this one, and the scary part is that most of the reported problems never seem to get resolved.) Actually I don't think my problem is related to whether the solution is a Web Application Project or a Web Site, because originally I had a Web Site solution and got the same error. But for now, I'd just like to understand how Silverlight is supposed to talk to the Web server, given the contents of an svc file that only identifies a C# source file containing the service when what gets deployed is a DLL.
Am finally connected now, no thanks to this brain-dead community Thanks, DASP community, for all your thoughtful answers (not). The ServiceReferences.ClientConfig file has a client endpoint element defined which of course has an address attribute. Since making my first post in this thread I've been trying to figure out the answer to my question myself. As near as I can figure out, the service needs to be in a folder named bin that is relative to the endpoint address. When VS2010 makes a new Silveright Web Application project, it places the .svc in the root of localhost, or the root of your project. Then when you build the project, the service assembly winds up in the bin folder off the .Web project. So presumably when you deploy all this to a live Website, the .svc file goes into the root of the Website and the service assembly goes into a directory called bin that lies off the root of the Website. So I did this and now for the first time since I tried accessing my service from the Website itself two weeks ago, everything works! I've been pulling my hair out over this for two extremely frustrating and depressing weeks and was ready to bring a consulting firm into my house for $250 an hour to solve my problem. I suspected it would only taken an expert five minutes to find out what was wrong because my Web Application project had no problem at all contacting my service when everything was run from my local PC. And I was right! Once I understood what is written in the previous paragraph, it took me all of two minutes to solve my problem! Judging from the number of unanswered threads about this on the Web, there seems to be a huge problem of being able to contact the service perfectly fine when the project is executed from within VS2010 and failing miserably when it is deployed to the live Website. Tons of unanswered questions are out there! I really feel for all these people, because until this morning I've been suffering from the same misery for the last two weeks! However, even though my real concern is now satisfied, I'm not going to mark this thread as SOLVED because my question wasn't "how do I connect to my service when it is located in my live Website," but how does the Silverlight application know where the code for the Web service is stored when it makes calls to it? You see, I'm still not sure what the answer to this question is or what the CodeBehind attribute in the .svc has to do with anything, since it doesn't point to anything at all that exists (explicitly) on the Website! So my question is more related to how all the plumbing works rather than about a problem I'm still having. Once I have the answer to this question, I should probably write an article on how to manually deploy Web Application Projects, since judging from the horrendous amount of unanswered threads on the Web asking this question, more easy to follow instructions on how to do this are sorely needed.
"no thanks to this brain-dead community"? You charmer! I see you've asked a lot of questions and received a lot of answers (while providing none yourself), but the minute that no one can help with one of your problems, the community is "brain dead"? Nice. Good luck.
Come on Frank..I've pointed to official forums. Don't you think they're a better place? Why? Well for two reasons: 1) Microsoft devs who author these tools hang out there. 2) MVPs who love helping and know the ins and outs hang out there. All the best, Mark
I have previously attempted to help you. It didn't work. In my last post, I offered to develop a small but relevant WCF/Silverlight sample project and this would have been a last ditch attempt to help you since offering advice in this forum clearly wasn't working. This won't be happening now. Your multiple system failures and seemingly inability to absorb most of the advice offered was certainly not due to lack of effort on my part. I won't be attempting to help you again. This community helps out where it can because it wants to. Not because it has to. No-one owes you anything. Don't bother responding; you are on my ignore list.
Same Problem with WCF RIA Service Hi Frank, I am new to this Silverlight and Hosting business. I have the same symptom with my Silverlight web application when deployed to the live server. However, my silverlight application uses a WCF RIA Service which contains an Entity Data Model and DomainService class. I also made sure that my DomainService class is accessible by the client by adding the attribute[EnableClientAccess()] to the DomainService class. All that is compiled into WebsiteName.Web.dll in the bin folder off the root. Looking both my Silverlight and my Web projects, i don't see any .svc file and could apply what you did for your solution. I was wondering if you had any experience with what i'm experiencing here anad if you could give me any pointer? Thanks a million, Quan