Wednesday, April 20, 2011

What Is Late Binding and Early Binding consoleapplication:

Binding: The process by which the CLR establishes a link between calling code and called code so that it can pass control flow and data between the two

Late Binding:

•    Binding information is gathered at run time.
•    The program stores the binding information in variables.
•    The called member is invoked either by using FCL methods, by using polymorphism, or by dynamic generation of an invoker method.

Early binding:
•    Binding information is gathered at compile time.
•    The compiler stored the binding information in assembly metadata (references).
•    The called member is invoked by using standard language constructs (such as method call and    propertylevent accessors)

As a programmer, you know that when your code calls a method, sets a property or field value, or adds or removes an event handler, the flow of control of the program temporarily passes to the called member, and then returns to the calling code after the called member has completed its processing. However, you may not have considered how the link is established between the calling code and the called code because this is usually the job of the compiler.

           When you are interacting with objects by using reflection, the compiler has no involvement at run time. However, the CLR must still establish a link between the caller and callee so that it can pass control flow and data (parameters and return values) correctly back and forth. The process by which this link is established is called binding and the mechanism of calling a member through an established link is called invocation.

No comments:

Recent Posts