Code was upgraded to use a function which may not have the same behavior
During upgrade, some Visual Basic 6.0 functions are upgraded to different Visual Basic .NET functions with different behavior. In many cases, this will not have an effect on your code; however, you should be aware of these differences and review your code to make sure that your usage of these functions is still appropriate.
Assigning a Byte array to a string
In Visual Basic 6.0, you could assign a Byte array to a string with direct assignment. When upgraded to Visual Basic .NET, this assignment is replaced by a function in the System.Text.UnicodeEncoding namespace. Because it is Unicode based, it expects an even number of bytes; an odd number of bytes will cause an exception.
The following example illustrates how this is upgraded:
' Visual Basic 6.0 Dim B() As Byte Dim S As String S = B() ' After upgrade to Visual Basic .NET Dim B() As Byte Dim S As String ' UPGRADE_TODO: Code was upgraded to use GetString, which may not have the same behavior. S = System.Text.UnicodeEncoding.Unicode.GetString(B)
What to do next
- Review the documentation for the Visual Basic .NET version of the function, and modify your code as necessary. In the above example, you would need to make sure that an even number of bytes are being passed when you assign to B().