Questions tagged [late-binding]

Late binding is a mechanism in which the method being called upon an object is looked up by name at runtime.

Late binding is a mechanism in which the method being called upon an object is looked up by name at runtime.

The specific type of a late bound object is unknown to the compiler at compile time. This is contrasted with early binding, where relationships between objects, methods are properties are established during compile time.

It is expected that questions tagged specifically relate to programming using late bound code. You should also tag your post with the specific programming language being used.

Example (VBA):

' late bound objects are declared As Object
Dim obj As Object
Set obj = CreateObject("Excel.Application")

Related Tags:

353 questions
3
votes
3 answers

Are there any cases where you have to use early-binding/inline event attribute in HTML/JavaScript

In my answer to the following SO question: What does event binding mean?, I made a passing remark that the use of inline-JavaScript/Early-Binding to bind JavaScript Events was 'often misguided' For example:
James Wiseman
  • 29,946
  • 17
  • 95
  • 158
3
votes
2 answers

Late binding of word in C#

I am developing an application which need to interact with 2003, 2007, 2010 versions of MSWord and PPT. I read some articles and found that Late binding is the best option. Could somebody post some sample code how to do it for word and PPT? Like how…
user734178
  • 43
  • 10
3
votes
2 answers

Is monkey patching/class-reopening really an example of reflection?

Apologies for the recursive nature of this question but the chosen answer to a question on SO got me questioning my understanding of reflection. I thought reflection was mainly about querying the internal happenings of a program while it's running.…
3
votes
1 answer

How to utilize C# attributes and reflection to inject/force late bindings on marked objects?

I love design patterns, the problem is that some can be really tedious to implement. For example, decorating an object that has 20+ members is just plain annoying. So, I wanted to create a nice library of design patterns to be applied to classes…
3
votes
1 answer

Late-bound version of RegisterInstance in Unity

In our project, we use Unity as a dependency injection framework. Now I am faced with a situation, where I need a late-bound version of IUnityContainer.RegisterInstance(). In ninject, the code I am trying to do, would look something like…
Daniel Fabian
  • 3,828
  • 2
  • 19
  • 28
3
votes
3 answers

Why is this Java method polymorphing by declared type and not runtime type?

This code: public class PMTest { private static class Runner { } private static class Server extends Runner { } private static class Task { public void delegate(Runner runner) { System.out.println("Task:…
Joe Casadonte
  • 15,888
  • 11
  • 45
  • 57
3
votes
0 answers

Why are late bound method calls designed to only work on public methods?

About the limitation As per Microsoft's official docs, late binding only works on public methods. Late binding can only be used to access type members that are declared as Public. Accessing members declared as Friend or Protected Friend results in…
jrh
  • 405
  • 2
  • 10
  • 29
3
votes
0 answers

Late binding object to existing instance via handle in VBA

This question pertains to VBA Internet Explorer automation What I have is an Internet Explorer window that loads a dialog box with buttons when the page loads. Here are the givens: The dialog box is of the "Internet Explorer_TridentDlgFrame"…
Singularity20XX
  • 321
  • 5
  • 20
3
votes
1 answer

Can I split a .net DLL without having to recompile other DLLs that reference the original one?

I have a C# project that builds into a single DLL with two classes, ClassA and ClassB. For project management reasons, I'd like to move ClassB into a separate DLL, leaving the original DLL with ClassA only. The problem is that I have other DLLs…
billpg
  • 3,195
  • 3
  • 30
  • 57
3
votes
1 answer

How can I load a VBA library reference and use it in the same procedure?

I have a VBA script for Excel that adds a small procedure in the active workbook. The final version will add a procedure that auto-saves backup copies of the workbook. The code requires the Microsoft Visual Basic for Applications Extensibility 5.3…
ChrisB
  • 3,024
  • 5
  • 35
  • 61
3
votes
1 answer

Delphi CreateOleObject events

There is a code: var myobject: OleVariant; begin myobject := CreateOleObject('SomeNamespace.SomeClass'); end; This COM object has events (for example OnClick). How should I connect to these events without importing TLB?
Yuriy Vikulov
  • 2,469
  • 5
  • 25
  • 32
3
votes
2 answers

Reflection using generics and late-binding. How to cast at run-time?

I am trying to use Generics with Reflection in c# to build a method that can handle multiple classes. I use a 3rd-party DLL that has a bunch of classes and on those classes, there is a method I call. They all return different return types, but I…
FDot
  • 33
  • 3
3
votes
1 answer

Excel VBA: Late binding reference

I'm trying to write some code for an add-in in excel, which grabs some data from an SQL Server. The code itself is working flawlessly, but somehow something got corrupted. It seems that the code will work fine a few times and then all of a sudden…
TroelsH
  • 33
  • 1
  • 4
3
votes
1 answer

Invoking GetMethod() on a System.__ComObject always returns null

I am using .NET 4.0 and dynamic to invoke members on a System.__ComObject at runtime. I instanciate the object in the following way: dynamic DrApi; DrApi = Activator.CreateInstance(SprImportedTypes.DrApi); The types are declared in a static class…
Parrish Husband
  • 3,148
  • 18
  • 40
3
votes
1 answer

Performance of executing late bound method call vs. switch/case method selection

While I've tagged this question with SSIS, it is not necessarily core to my question; So please keep reading if you're familiar with .NET reflection and code performance issues generally as you may be able to help! But in particular, the fact that…
Sepster
  • 4,800
  • 20
  • 38