Saturday, June 30, 2007

Referencing WCF service from a Windows Application

I was playing with Windows Communication Foundation over the weekend and came over one very interesting peculiarity.

My WCF service uses Basic Http Binding, is hosted by IIS, and has the following method:

[OperationContract]
public List<string> GetCustomerList() {...}
Let's use a Windows Applications as a client (just note the fact that Form1 class was created by default). We create a reference to the service through a "Add service reference" wizard. Nothing fancy. The generated reference consists of .map XML and .cs proxy class - very similar to the Web Service reference.

Now the weird stuff - how, do you think, our method was mapped? Most likely your guess is wrong, - the return type is a BindingList type (never worked with that one):

System.ComponentModel.BindingList<string> GetCustomerList();
Huh? Let's remove this reference and add it again but prior to that get rid of all windows form classes in the application. Here is a newly generated mapping:
string[] ListProducts();
Tada! This is more anticipated result, as a generic list and array should be serialized exactly the same way.

I can't understand a possible logic behind that. Maybe it's just a bug but it is still not clear to me what a possible connection could be there. I am too lazy to try map a service with the different bindings but encourage anybody to try.

Friday, June 29, 2007

C#: strings and string literals

I have a solid impression that I should have known this from the previous life. What is a difference between these pieces of code?

string sql = "SELECT SUM(Quantity)
FROM Production.ProductInventory"

string sql = @"SELECT SUM(Quantity)
FROM Production.ProductInventory"

The first will result in a compiler error while the second one - the string literal, is completely legitimate! No more tedious and ugly concatenations. Remember moving SQL statements back and forth between SQL Server console and Visual Studio? Ew!

Wednesday, June 27, 2007

Yippee ki yay!

I can't believe it, - Apple has missed the best spot for its money!
Two Mac dudes - permanently scratched McClane Willis and inarticulate Justin "Mac" Long, are saving the free world from a high-tech terrorist (who, I bet, is surfing the Internet with a Vista PC).
But why, why, why this formidable adversary is not played by John Hodgman?! 20th Century Fox and Apple would save tons of money on their budgets and impressed hordes would march straight from the theatres to iMac stores!

Oh, and if you wonder why, despite buying a Mac, you are still not cool - there is always a room for perfection :)

Tuesday, June 26, 2007

Orcas Beta 1 installation - do not forget Visual Web Developer!

Do not forget to install Visual Web Developer with Orcas. Otherwise Web projects will be unavailable (except for Web Control project) and Silverlight 1.1 Tools for VS 2008 will refuse to install, because "You must install Microsoft Visual Studio codename "Orcas" Beta 1 before installing this product."

To fix the problem you can re-run Orcas installation in add/remove components mode.

Monday, June 25, 2007

Windows Communication Foundation step by step.

Very well organized tutorial and reference book. John Sharp is a great writer and I bet, - great instructor, so he knows the importance of a learning plan depending of a student knowledge level. You will be able to build a decent WCF services upon reading first two chapters, while the rest of the book will guide you through the different aspects of this SOA breed. Better try examples on some capable environment, like Windows Server 2003.

Friday, June 22, 2007

Virtual Machine for Vista Home Premium Edition

It happened that I had to buy Vista laptop (tell me about the Microsoft Tax). To install Orcas (now VS 2008) one better have a virtual machine (if you don't want to bother with tedious upgrade process later on). There are three obvious choices - VMWare, Parallels and Virtual PC.

VMWare wasn't free and had spooky 200 Mb size download. Also for an inexperienced virtualist the choices they give you with free software are not really clear so it ended up put aside for a while.

Parallels is highly recommended by the people who I respect and it's widely praised all over Internet... By the Mac community... Not Windows. Windows users are definitely second-class citizens there. I was ready to pay but gave up after three days tweaking it back and forth trying to make Parallel Virtual PC merely read from CDROM - it invariably crashed. Next surprise was their non-existent support. On the forum people claim waiting for weeks for the callback promised within three days (for the paid product!). I expected something better from a flagship of the free world free-spirited Mac-Ruby-Open-Source community. Boo.

Virtual PC 2007 from the glorious Microsoft is free (hmm...) and promises no support for Vista Home Premium Edition(aha!). Anyway I tried in despair and it worked nicely! Tiny small download, familiar and simple setup - good stuff! The only trick is that there will be few glitches here and there until VPC Additions are installed. Mouse will not be shared between the host and guest and DVDROM, when mounted for guest PC can disappear from the host's sight. VPC Help has all the instructions.

Thursday, June 21, 2007

Return of the zombies

The blog is finally back from the dead - Blogger people marked it as a spam for some reason and it was in a coma for a while...


© 2008-2013 Michael Goldobin. All rights reserved