Ok, well first and foremost, I would like to apologize for my delay of this post. Lately work has been sucking my brain dry!! When I get home, I just want to stare at a wall and pretend the pain is gone. Don’t get me wrong, I love what I’m doing right now, but I get so deep into it that it even haunts my dreams!!
What is this haunting? Well, it’s Enterprise Services. I’ll get to the reason in just a bit. The code I posted a while back asked a simple question, what does the code output?………Bueller? Bueller? Bueller?...any one? Ok, here it is:
Interface type 'IGenericInterface`2'
Generic parameter type 'Int32'
Found an interger!
Generic parameter type 'String'
Interface type 'INonGenericInterface'
Press <ENTER> to exit.
The code is nothing but a simple reflection query against a generic interface to get its implementor’s base types for the generic arguments. Well, earlier that day I was playing around with having a ServicedComponent (Enterprise Service component) implement a generic interface and get the type of the generic parameter so I could dynamically load utility classes for the type. After implementing a similar approach as the first post, I hit the good ol’ COM wall straight on (Note: For those of you that don’t know this, the COM wall is about 40 feet high, 20 feet thick wall of raw steel).
Just as I ran regsvcs to register my component, I got a nice message telling me that “Generic types cannot be exposed to COM.” My heart was broken…and then I quickly realized, that it made sense! Although the .NET runs as a COM server and allows you to do lots of neat things inside of it, it still need to adhere to the rules COM sets. The component failed to register and I was left transaction-less. Needless to say, I had to refactor the way I was doing my service and try to push the generic interface into a lower layer.
As Paul Harvey says, now you know the rest of the story…