Re: Late Binding / CF

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



Thanks

"Christopher Fairbairn [MVP]" <christopher@xxxxxxxxxxxxxx> schrieb im Newsbeitrag news:#GuicNzqJHA.4364@xxxxxxxxxxxxxxxxxxxxxxx
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: Late Binding / CF
    ... VB.NET supports a feature called Late Binding. ... It is only when the application runs (i.e. "later" than compilation where ... Dim dr as Object ... binding as both classes implement the IDbDataAdapter interface and hence can ...
    (microsoft.public.dotnet.framework.compactframework)
  • 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)
  • 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: Error on submitting an Excel Sheet using Outlook
    ... If you use the code with Early binding you also get errors. ... He does have a Trio hooked up to Outlook. ... > Dim OutApp As Outlook.Application ... > Dim OutMail As Outlook.MailItem ...
    (microsoft.public.excel.programming)
  • Re: Type Library Reference Problem
    ... Dim sBuffer As String, Ret As Long, strAlias As String ... Dim varDomainNC As Variant ... > using late binding. ... GetObject is used when the object in question already exists. ...
    (microsoft.public.access.modulesdaovba)