Jelle Druyts .NET Consultant
Just another ignorant weirdo from Antwerp, Belgium trying to make sense out of it all
It seems that Don Box is quite into continuations, iterators, anonymous methods and all sorts of other mysterious corners of programming lexicology lately. Some of the stuff he's showing is some pretty cool and nifty higher-order logic with C# 2.0, although I don't really see that happening in real-world enterprise applications any time soon. It's just another tradeoff between programming power and readability (which is, of course, directly related to maintainability).
Throughout his posts, generics are ubiquitous - and rightly so, since they're one of the most powerful and appealing new constructs in .NET 2.0. Funny thing is, Indigo (his brainchild, one might say) doesn't really seem to dig generics at the service boundary: if I specify a generic interface as an Indigo [ServiceContract], it will apparently blow up at runtime...
[ServiceContract]
Take the following and run it into the Indigo/Avalon (affectionally called WinFX) Beta 1 RC that was just released:
[ServiceContract] public interface IServiceProvider<T> { [OperationContract] T PerformService(T item); } public class ServiceProvider<T> : IServiceProvider<T> { public T PerformService(T item) { return default(T); } } class Program { static void Main(string[] args) { Uri serviceUri = new Uri("http://localhost/ServiceProvider"); ServiceHost<ServiceProvider<int>> host = new ServiceHost<ServiceProvider<int>>(serviceUri); host.AddEndpoint(typeof(ServiceProvider<int>), new BasicProfileBinding(), "ep"); host.Open(); Console.WriteLine("Running. Press any key to stop..."); Console.ReadLine(); } }
If I run this, all will seem fine. Until I request the wsdl (http://localhost/ServiceProvider/ep?wsdl): it gives me an HTTP 500 internal server error. Doing the same without the generic interface (replacing T with int directly) will work just fine.
T
int
I wonder what went wrong. Probably something in the reflection part where they don't deal with generics properly yet...
Anyway, it's great to finally have one machine with Visual Studio .NET 2005 Beta 2 and WinFX Beta 1 RC working together. A largely undiscovered land lies ahead, and I've got my backpack ready