Generics at the Indigo service boundary#

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...

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.

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 :-)

Blog | Programming | .NET | Indigo | Whidbey
Comments are closed.
All content © 2012, Jelle Druyts
On this page

Recent Photos
www.flickr.com
This is a Flickr badge showing public photos from Jelle Druyts. Make your own badge here.
Advertising
Top Picks
Statistics
Total Posts: 350
This Year: 0
This Month: 0
This Week: 0
Comments: 530
Archives
Sitemap
Disclaimer
This is my personal website, not my boss', not my mother's, and certainly not the pope's. My personal opinions may be irrelevant, inaccurate, boring or even plain wrong, I'm sorry if that makes you feel uncomfortable. But then again, you don't have to read them, I just hope you'll find something interesting here now and then. I'll certainly do my best. But if you don't like it, go read the pope's blog. I'm sure it's fascinating.

Powered by:
newtelligence dasBlog 2.0.7226.0

Sign In