When you use a dynamic keyword, each code associated with a dynamic variable will be compiled at runtime DLR. When you call a method using a dynamic variable, the actual signature of the method is unknown at compile time, as well as the type of method returned and everything connected with it, creating something that Eric Lippert called "Dynamic infection" :
"As I pointed out last time, when the call argument is dynamic, the coefficients are pretty good that the compiler will classify the result of the call is also dynamic; smoothing. In fact, when you use almost any operator in a dynamic expression, the result is dynamic type, with some exceptions. ( "is", for example, always returns bool.) You can "cure" an expression to prevent its dynamism from spreading by dropping it onto an object or any other non-dynamic type that you like; ix dynamic object in an object is the identity transformation ".
WCF internal components use many interfaces and abstractions and the well-known DLR restriction on abstractions and interfaces, where DLR does not allow the correct type. (Also see this discussion )
I was able to properly invoke ChannelFactory by reflecting and discarding the parameter to other types (and also trying to call the service using the wrong type). The problem should be related to DLR.
I cannot debug DLR compilation, but the problem may be related to the "dynamic infection" and the interface resolution error. When βinfectedβ, each part of the WCF call can be compiled at run time, and a type resolution error can create some contours of contours in some cases with corners, for example, implementing an overridden method that calls the base method, and the base class was incorrectly allowed to do the same same child class.
Some WCF internal elements follow additional instructions when connecting a debugger ( Debugger.IsAttached ), which usually includes statements, checks, and attributes. Additional instructions may provide some information that kills "dynamic infection" and avoids a fictitious infinite loop.
lstern
source share