Carlos,
I don't use it for late bound calls, as much as eliminating the need for
downcasts.
Instead of Reflection, have you considered using CallByName?
When I use it (Option Strict Off) I limit it to as few as methods as
possible in as small a class as possible, which means I tend to have an
extra light class that is Option Strict Off. Also I will turn Option Strict
On to help eliminate any obvious errors, then turn Option Strict Off to run
the code. Then depending on the usage of the Option Strict Off class, I will
refactor it inline into the original class... Possibly eliminating the
Option Strict Off class.
As I stated I normally use Option Strict Off to encapsulate downcasts, which
I can easily add inline, however all the downcasts can make the code harder
to read. Hence the separate class to get "things working" then use the
Refactoring to improve the code.
| Maybe I would choose Option Strict Off if I could apply that option only
to
| a region of code rather than to the whole file...
As I suggested VB 2005's partial classes will simplify this (using Option
Strict Off), as I can put all the Option Strict Off stuff in one source
member & have it be a partial class of a larger class that is Option Strict
On. Eliminating the need for 2 classes...
http://msdn2.microsoft.com/library/y...us,vs.80).aspx
Something like:
' Something.Interop.vb
Option Strict Off
Partial Class Something
Public Sub DoSomeLateBinding()
...
End Sub
Public Function EncapsulateDowncast() As SomethingSpecific
...
End Sub
End Class
' Something.vb
Option Strict On
Partial Class Something
' the majority of the class definition
Public Sub DoSomething()
DoSomeLateBinding()
Dim x As SomethingSpecific = EncapsulateDowncast()
End Sub
End Class
Notice how the Something class's definition is split between the
Something.Interop.vb & Something.vb files. The Something.Interop.vb contains
implicit downcasts & late bound code, while Something.vb contains early
bound code & explicit downcasts.
Hope this helps
Jay
"Carlos J. Quintero [VB MVP]" <ca*****@NOSPAMsogecable.com> wrote in message
news:eW**************@TK2MSFTNGP09.phx.gbl...
|I never use Option Strict Off, even dealing with COM Interop, I use
| Reflection if I need to use late bound calls, even if it takes more code.
| Maybe I would choose Option Strict Off if I could apply that option only
to
| a region of code rather than to the whole file...
|
| --
|
| Best regards,
|
| Carlos J. Quintero
|
| MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
| You can code, design and document much faster.
| Free resources for add-in developers:
|
http://www.mztools.com
|
| "Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> escribió en
| el mensaje news:ep**************@TK2MSFTNGP15.phx.gbl...
| > Carlos,
| > I normally run with Option Strict On, however Option Strict Off is very
| > useful some times. For example when dealing with COM interop, especially
| > COM
| > objects written for VBScript where all return values were defined as
| > Variant...
| >
| > I'm looking forward to Partial Classes in VB 2005 as they will allow me
to
| > isolate just the parts of my class that needs Option Strict Off to its
own
| > source file!
| >
| > Jay
| >
|