Early and Late Binding in Asp.Net

 
Early Binding
The Visual Basic compiler performs a process called binding when an object is assigned to an object variable. An object is early bound when it is assigned to a variable declared to be of a specific object type. Early bound objects allow the compiler to allocate memory and perform other optimizations before an application executes.

Dim FS As FileStream
FS = New FileStream("C:\tmp.txt", FileMode.Open)
FileStream is specific object type the instance is assigned to Fs this is early binding.

Late Binding

In late binding when an object is assigned to a variable declared to be type of object. the object of this type hold the reference of any other object.

Sub TestLateBinding()
   Dim xlApp As Object
   Dim xlBook As Object
   Dim xlSheet As Object
   xlApp = CreateObject("Excel.Application")
   'Late bind an instance of an Excel workbook.
   xlBook = xlApp.Workbooks.Add
   'Late bind an instance of an Excel worksheet.
   xlSheet = xlBook.Worksheets(1)
   xlSheet.Activate()
   xlSheet.Application.Visible = True ' Show the application.
   ' Place some text in the second row of the sheet.
   xlSheet.Cells(2, 2) = "This is column B row 2"
End Sub

when ever possible try to use early binding because it allow to allocate memory to object at compile time and perform optimizations at compile time that will be helpful for our application.

Early-bound objects are significantly faster than late-bound objects Another advantage to early binding is that it enables useful features such as automatic code completion. Early binding also reduce the overhead at run-time it reports the error at compile time.

By the help of reflection in .NET with which you can dynamically load assemblies and inspect its members and call them.
we upload next article how to achieve late binding by reflection.