KnowDotNet

Converting to VS2005 - 102 Late Binding Warnings

How to get rid of them

by Les Smith

When I converted an application from Version 1.1 to VS2005, I had literraly hundreds of warnings.  Many of them are Late Binding Warnings.  Can I get rid of them?

I recently converted a large project from version 1.1 to VS2005 and found that I had hundreds of(more than 102) warnings.  Many of them are Late Binding Warnings.  Since my application is debugged and the Late Bindings are not a problem to me (I probably will get hammered for this, but remember that I am a confirmed pragmatist, not a purist), I just want to turn them off.

There is a lot of new stuff in VS2005, and a lot of it is found in the Projet Property Dialog.  You should spend some time previewing it.  The Compile Tab is shown below.

Project Property


You can see that you can turn off the Late Binding Warnings by clicking the drop down arrow next to Late binding... and choose none.  Notice that there are other warnings that you can either turn off or turn into errors, depending on your viewpoint.

The next error I ran into was "Implicit Conversions to Integer or String, etc."  After wrapping several of them with CType(...), I decided to write a few macros which may be of use to you.  They are shown below and you may want to expand on them.

    Public Sub CtypeInteger()
        
Dim ts As TextSelection = DTE.ActiveDocument.Selection
        
Dim sel As String = ts.Text
        sel =
"CType(" & sel & ", Integer)"
        ts.Delete()
        ts.Insert(sel)
    
End Sub
    Public Sub CtypeString()
        
Dim ts As TextSelection = DTE.ActiveDocument.Selection
        
Dim sel As String = ts.Text
        sel =
"CType(" & sel & ", String)"
        ts.Delete()
        ts.Insert(sel)
    
End Sub
    Public Sub CtypeTextSelection()
        
Dim ts As TextSelection = DTE.ActiveDocument.Selection
        
Dim sel As String = ts.Text
        sel =
"CType(" & sel & ", Envdte.TextSelection)"
        ts.Delete()
        ts.Insert(sel)
    
End Sub

It turns out that if you double-click on the error in the Task List, the offending code will be highlighted and then you can double-click the respective macro in the Macro Explorer.

Hopefully, this little article can save you some time in your conversion effort.