My first post on this forum, and it's going to be very similar to lots of other posts I saw on the forum. Apparently everything has to be "just so" or Silverlight Websites just won't work. Like programs in general, I suppose. But mine is so close, yet so far. Hosted on DiscountASP.NET it actually comes up, as long as I don't give it the Web.config file. Of course then I can't communicate with my database. I developed an ASP.NET-hosted Silverlight project as a Web Site rather than a Web Project. I'm so green at Website development that I hardly know what that means. I just followed the "recipes" in Matthew MacDonald's book, "Pro Silverlight 3 in C#" and managed to get a Website running perfectly on my PC. It uses WCF to implement a couple dozen ServiceContracts accessing my DiscountASP.NET database. The ServiceContracts support a couple dozen Silverlight pages and ChildWindows and it all works -- on my PC but not on DiscountASP.NET! That seems to be a broken record on this forum. My first attempt at Web programming, too. I chose Silverlight because I am a fairly prolific WPF programmer. I was delighted when it popped up on the DiscountASP.NET site, but I was failing to connect to my database. That's when I realized my Web.config file was in the wrong place. But putting it in the right place (the Website root) instantly produces an error reported in the browser as this: "Description: An error occurred during the processing of a configuration file required to service this request. Please review the specified error details below and modify your configuration file appropriately [without giving a clue how to do that]. "Parse Error Message: Unrecognized attribute 'targetFramework'. "Source Error: Code: Line 6: <configuration> Line 7: <system.web> Line 8: <compilation debug="true" targetFramework="2.0.50727.4016 "/> Line 9: </system.web> Line 10: <system.serviceModel> "Source File: E:\web\parisphoto\htdocs\web.config line 8 "Version Information: Microsoft .NET Framework Version 2.0.50727.4200; ASP.NET Version: 2.0.50727.4016" I have no idea where those version numbers came from. I'm building on VS2010 and running .NET 4.0 and Silverlight 3. Maybe that's a clue as to what's wrong. But I'll bet that all I have to do is figure out how to communicate with the database and everything is going to work perfectly on DiscountASP.NET, just as it does on my PC.
I removed targetFramework="2.0.50727.4016" and the problem went away. It was supposed to be "4.0" anyhow. The 2.0 string was just an experiment that didn't fix the problem and I forgot to return it to 4.0. 4.0 didn't work either. Had to take out the entire property. Now the Website comes up, but it still can't find the database, which it can find just fine on the PC. But first things first. What's worse is now I'm getting compilation errors. It suddenly says it can't find System.Linq and the ObservableCollection namespace. Yup, it needs targetFramework=4.0 to find those namespaces. But with the targetFrmework specified I'm back to the same error reported in the original post. So I'm damned if I do and damned if I don't. What is the solution?
I made several more changes to Web.config that seemed to revert the version of .NET to before there were things like the var keyword which I think came in with .NET 3.0, didn't it? Anyhow, I had dozens of them and I got rid of them all (I'm desperate here, hardly knowing what I'm doing, in spite of over 100,000 lines of WPF 4.0 under my belt). There were also other .NET 3.0 constructs that no longer compiled and I had to replace them with more primitive constructs. Eventually I got everything to compile again and I've got the Silverlight application running from my DiscountASP.NET site and now I'm at the point where the connection string isn't hooking up with the database, which it did just fine when everything was running from the PC. This is a SQL Server database that I signed up for through DiscountASP. Those credentials still work in SSMS, so they should work on my DiscountASP Website, right? But they don't. I'm so green at this I don't even know what information to add to help anyone figure out what's wrong. So please ask questions so I know what to tell you.
Hiya Frank, You're doing a bit more with this than I have or I'd jump in. I'm curious why you chose to use WCF...Needed it or wanted to try it? Yes in VS and Blend Website and Application are much different. Which Silverlight version are you targeting right now? Only VS or with a version of Blend too? I'm going to try and help, don't want to see a WPF brother pull his hair out. ;-) All the best, Mark
Hi, Mark. You asked why I'm using WCF, as if it's some kind of big deal. It isn't at all. It's simple as pie. I'm using WCF because under VS2010 and Silverlight it's supremely easy to use, and before I started this project, I knew virtually nothing about developing Websites. I'm doing all this from Matthew MacDonald's book, Pro Silverlight 3 in C# and that's what he describes you should use for Web services, probably because it's so simple. I have no idea how to use any other technologies, or even what the names of any of them are. What would you suggest? I used WCF because there is about a half hour learning curve to start creating service contracts. I don't want to use anything that would take weeks of study to get off the ground. What I gather from my reading is that there are so many new technologies springing up every week because the old technologies are so horrendous to use and the new things are supposed to make things simpler. But they are new things that you have to learn. It's probably also why I'm just sticking with straight ADO.NET, because that's what I know, even though there are more "elegant" solutions now. I'm targeting Silverlight 3 because I'm paranoid about installing beta software. I've had horrendous problems trying to uninstall it when the released version came out. I realize I should be using beta software in virtual machines, but I'm not there yet. BTW, I was laid off in January, 2009 and haven't been able to find employment since. I'm on my own, trying to develop a product I can sell (which I've actually done now), but I need a Website to market it. That's what I'm working on now. Since being laid off, I've never worked harder in my life. When you've got a steady job, you have gobs of free time. I work at least 12 hours a day, 7 days a week, trying to keep up with technologies and getting a salable product out the door.
Have you tried using SilverLight 4 / RIA services with ASP.NET 4.0? I talked to Tim Heuer over email about using SilverLight 3 with WCF and it is rather cumbersome. With SL 4 & RIA, things are much simplier.
Good chat guys. @Frank. . .It's not that simple to me. ;-) I'll be 50 next year and began cramming Microsoft technologies into my head in 1987. Space is limited after busting 3 helmets over the 16 years I raced bikes. @Bruce. . .I agree and have been learning SL4 and RIA with Victor http://victorgaudioso.wordpress.com/ All the best, Mark
I'm far from ready to switch basic technologies to solve this problem. I'd rather attack the problem directly, which I've done very little of so far, and basically have not received any suggestions from anyone yet that is directly applicable to what I've done, which admittedly no one knows what that is, since I've been very sketchy in my descriptions of what I've done. The other thing is, I'm not set up for virtual machines (I know I should be) and I've had extremely bad experiences installing beta software (actually uninstalling it), so I'm not going to Silverlight 4 until Microsoft releases it out of beta. (Last bad experience: trying to uninstall VS2010 RC which I needed to do before installing the released version of VS2010 Professional. The uninstall procedure instantly told me I was running the setup.exe program in Compatibility Mode, which I was not! It took Microsoft eight hours over a period of three days on the phone with them to get the problem solved. They never did find out the actual cause of my problem and they ended up manually uninstalling all 30 or so parts of VS2010 RC with msiexec. That alone took three hours.) Hopefully I will not have to backtrack too much to get the Website talking to my database. There must be something really simple I'm not doing right, since I had this all working perfectly on the PC. I'd rather try to attack the problem directly, at least for a while, before diving into technologies entirely new to me that could postpone my going live for weeks if not months. I'm hoping to be up and running within the next two or three days. With that in mind, I'm going to make another post in this thread after this one describing exactly what I did in going from the PC to the Website. Maybe somebody will be able to tell me what I'm missing. I just can't connect to my remote database, simple as that. The rest of the Website comes up fine. Unfortunately the database functionality is where all the true value is: what keeps track of customers and what charges them money for my software product. So if I can figure out why I can't connect to my database, I'm fat city. I have no trouble talking to the database through SSMS and before I moved things to DiscountASP.NET I had no trouble connecting to the database from my Silverlight application. Of course in both cases, I was connecting to the remote database through software running on my PC. Now I'm trying to connect to the remote database through a remote Web service on Discount.ASP.NET. In any case, I don't think my problem is something stupid like having a bad connection string. My problem may be something stupid, but not that stupid.