Re: Late Binding / CF
- From: "James Hetfield" <james@xxxxxxxxxxxx>
- Date: Wed, 25 Mar 2009 16:12:16 +0100
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@xxxxxxxxxxxxxxxxxxxxxxxBut 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
- References:
- Late Binding / CF
- From: James Hetfield
- Re: Late Binding / CF
- From: Christopher Fairbairn [MVP]
- Late Binding / CF
- Prev by Date: Re: Window CE Setup VS2005
- Next by Date: Get Device Hardware infos
- Previous by thread: Re: Late Binding / CF
- Next by thread: Restart Windows Mobile Device Programatically
- Index(es):
Relevant Pages
|