To Emit Or Not To Emit:
One of the things that Microsoft's Indigo (Beta 1) allows service providers ("providers") is to expose as a service any method (even private ones)
This poses the following questions: how to reach a private method after it has been compiled?
The problem is compounded by the fact that Amber's Host ("the host") needs to use an Appdomain per type exposed as a service (which requires MarshalByRefObject) to protect providers from tripping each other.
By the time the new Appdomain is up, the object invoking the host, is not longer type "A" but MarshalByRefObject.
A direct use of reflection does not
seem to be working. So far these are the following options that I have researched to solve the problem:
*) Use System.Convert.ChangeType. It may require the providers to implement complex interfaces. We may want to avoid this.
*) Use a double shot of reflection: one for dissecting MarshalByRefObject and the other to dissect the provider's type.
*) Use System.Reflection.Emit and modify the provider on the fly. Risky?
The easiest solution would be to forget reusing the instance implementing IService, the one invoking the host, this would eliminate a lot of trouble but it may be too expensive in some cases.
I will update you guys as soon as I have something working...
Labels: Amber, open source