Re: Late Binding / CF

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi James.

"James Hetfield" <james@xxxxxxxxxxxx> wrote in message
news:%23Ev7EjiqJHA.724@xxxxxxxxxxxxxxxxxxxxxxx
But I get the error "Late Binding not supported"

Is there an easy way to get around this problem?

I assume there is some additional code after the snippet you provided, such
as something like the following:

Dim count as Int16 = dr.FieldCount

It will be this code which is causing the late binding error during
compilation.

VB.NET supports a feature called Late Binding. The 'dr' variable is typed as
Object, yet on the desktop you can call methods and properties on it, as if
it was typed as SqlCEDataAdapter or SqlDataAdapter.

It is only when the application runs (i.e. "later" than compilation where
this check is usually made) that the runtime determines if these methods
actually exist and "binds" to them or throws an exception.

At compile time the compiler only knows it has a variable of type Object, so
it can not determine if the method or function calls you make in this manor
are valid.

Although late binding works on the desktop, as discussed in the article
"Differences from Desktop in .NET Compact Framework Development" (available
at http://msdn.microsoft.com/en-us/library/t340010s.aspx) it is not a
supported feature when targeting a PDA.

As such replacing the line

Dim dr as Object

with

Dim dr as IDbDataAdapter

Should allow you to work with either data adapter. This doesn't require late
binding as both classes implement the IDbDataAdapter interface and hence can
be guarenteed at compile time to contain the methods and properties it
defines.

Hope this helps,
Christopher Fairbairn


.



Relevant Pages

  • Re: Ron Garret considered harmful [Re: DEFSTRUCT and lexical environment]
    ... environment as defined in the common Lisp Standard and you cannot ... macros are expanded before compilation. ... That denotation is a binding. ...
    (comp.lang.lisp)
  • Re: Symbol macros dont capture their lexical environments?
    ... think that answer is a little facile, particularly in light of the HCF ... hyperbole that you yourself brought up. ... we've got information crossing the boundary between compilation ... isn't bound to a _value_ and the binding isn't a lexical binding, ...
    (comp.lang.lisp)
  • Re: Late Binding / CF
    ... It will be this code which is causing the late binding error during compilation. ... It is only when the application runs (i.e. "later" than compilation where this check is usually made) that the runtime determines if these methods actually exist and "binds" to them or throws an exception. ... Dim dr as Object ... This doesn't require late binding as both classes implement the IDbDataAdapter interface and hence can be guarenteed at compile time to contain the methods and properties it defines. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Separating evaluation and compilation environments.
    ... >> Because it does in fact have a binding. ... > There is a reference to a variable X in the body of the (MACROLET BAR) ... And there is a compilation ... compilation environment, is there not? ...
    (comp.lang.lisp)
  • Re: repost: need help trying to automate Outlook from XL, with late binding
    ... late binding), then you just need to use the intrinsic value of that ... Now go back to your sub and put this at the top (under your Dim statements) ... In your EB code, you declare olApt as ... > where different levels of the libraries are co-existing, ...
    (microsoft.public.excel.programming)