Skip to content

October 7, 2007

Day 4 – Chapter 2

Chapter 2 is sort of interesting. It goes into how to build a host for your service. “Host for my service??” you say. Yep that’s right, in Chapter 1 we hosted our service within IIS, however Chapter 2 has many many treats for us. We learn how to build a host for our services.

Moving on, I like that the book goes into WPF a bit, and I must say I like WPF so far. I always meant to mess with it but never did. A lot of people I know have and I was even part of a UI SIG, but I never really felt the need to mess around with any of the early BETAs. I think the biggest turnoff was that if you had an older version of the XAML you couldn’t run it in a newer interpreter. It was a while back now, but I had some .8x sample and I was runing a .9x interpreter, and the lack of backward compatability was a huge turnoff. No reason to waste time learning the BETAs when I can wait, get a book and use the real deal.

So back to the book, the author has you manually type in some XAML… which if you like typing is fine, but I am lazy so I just used the designer to do basically the same thing. Something all may not be aware of if you haven’t used WPF is that everything is a container. So a button could contain a button. That being said, if you have a label, I didn’t see a “.Text” property. I did however see a “.Content” property, so that’s where you put the contents of your label, in this case the text. To further confuse people, Textboxes have a “.Text” property. So in that respect we’re back to the old VB6 days of Label.Caption and Textbox.Text… confusion! … well for some anyway. Definetely not consistent. The other thing that will make your head spin is the amount of properties that you can set per control. That is actually nice. There are a lot of things present that you could not do in the past. The only thing to mention there is that a lot of properties are padded with “Is” so IsEnabled = Enabled , IsReadOnly = ReadOnly and so on.

Back to WCF though. Going into the code for the form presents something that always bugged me. Renaming a WinForm is sucky, and it still is even with WPF. You have to manually change a ton of stuff. This ties back to a “we won’t change code” philosophy that Microsoft adopted, but in certain instances it would be nice to ask me and then if I say Yes do the dirty. Maybe in VS2008…

After you build the application to start and stop the WCF service you add the console application you built in chapter 1. They provide it for you in chapter 2, as part of the solutions. I just added what they provided. It was kinda disappointing that I couldn’t get the thing running as of right now. I got the service to start and the client app to start but I was getting a fault in the service. Since the DLL they referenced was their own, I couldn’t change the code to figure out the fault.

So I just added my work from Chapter 1 and removed the reference to their DLL. I am getting a DLL or one of it’s components not found error:

“An error occurred creating the configuration section handler for dataConfiguration: Could not load file or assembly ‘Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0×80131040) ”

I tried resetting the reference to the EL components but that was a no-go. I changed the Copy Local property but still got the same error. At least I know its someting going down with the EL and not my work in the examples. I may just use my own DB connectivity component and skip the EL since I’ve never had much luck with it. It has a ton of functionality, but it gets an F in the intuitive department. If anyone knows of any books for working with it let me know. It is quite popular and I hate it…. lol.

Anyway, the most important part of this chapter is that you can define different connection points to your service. You don’t have to use HTTP as you did with web services, you can use TCP. The book has you create a TCP endpoint and it has you change the client application to use that endpoint. This is really nice because you are no longer bound to IIS or HTTP. 

That being said that is the last part of the chapter. We’ll get to that shortly. The book goes over bindings in WCF. Think of bindings as a collection of properties that describe how the endpoint will work. Correct me if I’m wrong there. :) The book tells all about the bindings that are provided by the framework, and you can even write your own. That however is beyond the scope of the book, as the author puts it. I would have liked it if the book went into the individual binding elements a bit more and explained them. It talks about how you can specify if you want to use transactions or security and so on, but never really gives an example of how to edit that. Maybe in the following chapters… I hope.

The last part of the book has you set up your WCF Service to run within a Windows service that you write. I did not want to add a service to this box so I just read that part and didn’t do the exercise. I already know how to create services and the WCF work involved was similar to what was done earlier with the WPF application.

I must say that thus far I really like WCF. There was a lot of thought put into this. I always thought that WCF was just the next version of Web Services and that the two would be very similar. As it turns out WCF is much more than just that, it is a HUGE … I was going to say improovement but it’s not that, it is completely new and different. I like it!

It always seems like there is the side of Microsoft that can pump out stuff like WCF and then there is a naughty side. I like how WCF works and how there are contracts and so on. I wish that the rest of the Dev tools would follow suit. The major thing that scares me is LINQ, it just seems too… free and wreckless. I keep saying that but keep in mind I have not researched it or used it in depth, but it just seems like one of those things that has the potential of being used all over and creating lots and lots of problems. I don’t like things that make it “easier” for just anyone to do this. A certain degree of complexity is needed to keep the ramrods out. This is why I HATE MS Access, it allows people that can barely function themselves write applications for, more often than not, complex business processes. Then someone like myself gets tortured and has to look at the VBA and debug it and puke when I see the code in there. I feel dirty just thinking about it.

Anyway the point is that WCF seems very good thus far. I was kind of scared to go into this chapter thinking “How the heck am I going to write something that will replace IIS?”, but it was really easy. I can think of a lot of uses for the tools that WCF provides, especially where I work. There are lots of platforms, lots of async stuff goes on, and WCF could really help.

The only thing I’ll mention is that there are no exercises at the end of the chapters. They are within the chapters themselves. I may just do a half chapter per day due to that just so that I get enough content for the whole month… that and I have training this coming week for 4 days. Which means I get done with work at 5, come home, have my pre-workout meal, go to the gym, post-workout meal, cook dinner, eat dinner, read book and post. That may put me in the 1AM range, and I like my sleep. I just reset my bio-clock to get tired at 10pm… and wake at like 6. No reason to biff that… I don’t know I’m kind of a Nazi( or stubborn ) about anything I do so I am going to try and stick with full chapters, but we’ll see.

Read more from Uncategorized

Share your thoughts, post a comment.

(required)
(required)

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments