can i use late binding with the vb6 com dll

  • Thread starter Thread starter Mullin Yu
  • Start date Start date
M

Mullin Yu

hi,

my project requires some vb6 com dll. now, i use the Add Reference to add
them to the project. but, this approach binds the binary (classid) of the
dll. once the binary compatibility of the dll is broken, i need too remove
the reference, and then add a new reference. finally, compile the project
again.

can i use the approach of late-binding like vb6? use createobject("aaa.bbb")

thanks!

mullin
 
Mullin,

Yes, you can. You can use the classes in the System.Reflection
namespace (along with System.Type) to reflect on methods in a COM object.

Hope this helps.
 
Nicholas Paldino said:
Yes, you can. You can use the classes in the System.Reflection
namespace (along with System.Type) to reflect on methods in a COM object.

Sorry if I am missing something, but I think what you're describing is not
late binding.

In your scenario, wouldn't you need to tlbimp a com component (or "add
reference") at design time in order to reflect on it?
If that is the case, then it is static binding.

Mike
 
i just want to do the early binding as vb6

early binding
dim o as xxx.xxxx
createobject("xxx.xxx")

late binding
but not dim o as new xxx.xxx

even changing the class-id of the com dll, my application still works.

mullin
 
Mullin Yu said:
i just want to do the early binding as vb6

early binding
dim o as xxx.xxxx
createobject("xxx.xxx")

late binding
but not dim o as new xxx.xxx

These are both examples of early binding in VB6. Late binding looks like
this:

dim o as object
set o=createobject("xxx.xxx")
even changing the class-id of the com dll, my application still works.

In your example, IIRC, as long as you have "dim o as xxx.xxx", you will not
be able to change the interface. Resolving the CLSID at runtime via the
progid, "xxx.xxx" in this case, allows your to change the CLSID, but not the
IID.

The only way to achieve true late-binding is via the IDispatch interface,
which VB6 represents as the generic "object" type.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top