VBUC Documentation | Mobilize.Net
Mobilize.NetForumsBlogDocumentation Home
  • Mobilize.Net VBUC
  • Introduction
  • Install and Licenses
  • Get Started
  • Migration Guide
  • VBUC Features
  • Mappings Grammar
  • Generated Code
  • Upgrade Options
    • Data Access
    • Grids
    • Microsoft
    • Sheridan
    • Others
    • Code Conversion
    • C# Features
  • Third-party controls
  • Best Practices
  • EWIs
    • Warnings
    • Issues
    • ToDos
    • Notes
  • Issues and Troubleshooting
    • Microsoft.VisualBasic Uses
    • Safe and Unsafe Methods Layer
    • Third Party Components
    • Migration Process
    • Classic ADO Conversion to ADO.NET
    • VB6 and .NET integer division
    • VB6 On Error Statements
    • Running a .NET Core application in a machine with no Visual Studio installed
    • Databases issues
    • Unsupported assemblies on .NET Core and .NET 5
    • Icon Extraction Issues
    • HTTPS sites are not loaded in Windows XP
    • Short-Circuit Boolean Logic in C#
    • Assessment Report Issue
  • Knowledge Base
    • FAQ
      • Does the VBUC support the Sheridan VB 6.0 controls suit?
      • How effective is the Visual Basic Upgrade Companion tool at converting an application's front end?
      • What controls does the Visual Basic Upgrade Companion tool supports?
      • How does the VBUC handle VB6 Collections?
      • Can the VBUC migrate intrinsic VB6 functions and libraries?
      • Where is the source code for the support (helper) classes used by the VBUC?
      • How does the VBUC convert ADO to ADO.NET?
      • Can the Visual Basic Upgrade Companion tool be customized?
      • What are Stubs?
    • How-To
      • App.Config and Database Access
      • Avoid reflection in Hot Paths
      • Convert ESRI ArcGIS Visual Basic 6.0 applications to .NET
      • Drag and Drop Conversion Steps
      • Inserting elements in a ListView
      • String vs StringBuilder
      • Word Automation in VB6 vs .NET
      • Configure default Factory Database provider
      • GetPrivateProfileString Windows API working in migrated code
      • Upgrade projects with shared files
  • Release Notes
Powered by GitBook
On this page
  • 1707 - The resulting shared file would differ depending on whether all or some projects are migrated.
  • 2041 - The following line was commented
  • 6016 - Structure %1 should be within the shared file due to its use in Declare statement for a Windows API
  • 6017 - Inaccessible enum value %1 was changed to its numerical value %2
  • 7001 - The following %1 (%2) seems to be dead code
  • 8001 - Element %1 was removed
  • 8008 - Element %1 is obsolete and should be removed

Was this helpful?

  1. EWIs

Notes

The following are some of the most common Notes generated by the Visual Basic Upgrade Companion.

PreviousToDosNextIssues and Troubleshooting

Last updated 1 month ago

Was this helpful?

1707 - The resulting shared file would differ depending on whether all or some projects are migrated.

Description

This EWI appears in shared files between two or more projects. In VBUC, you can upgrade the projects using one of the following options:

  1. Upgrade Projects: Clicking this button will upgrade the entire solution.

  2. Upgrade Selection: Select specific projects to upgrade and click this button to upgrade only those selected projects.

The main difference between the two options lies in the scope of migration. The Upgrade Projects option migrates the entire solution, preserving the context and settings of all projects. In contrast, Upgrade Selection upgrades only the selected projects, which may result in significant variations in the shared files, as they are upgraded based on the context of just those chosen projects.

Recommendation: We recommend always using the Upgrade Projects option to ensure a consistent and complete migration. However, if you choose the Upgrade Selection option, we strongly recommend identifying the projects that contain shared files beforehand. Once you have located these projects, select them and click the Upgrade Selection button to upgrade them properly.

For more information on how to identify projects with shared files, visit

2041 - The following line was commented

Description

This EWI appears if for some reason the line can cause compilation errors and therefore the migration tool decides to comment it out.

API Calls are Moved

The VBUC performs some code refactoring on any of the API calls that it finds by consolidating all those calls into new files. When this happens, the original VB6 Declare API statement is commented out. This line is just left as an information reference. The recommendation is to remove this line.

See also:

VB6 Original Code

Public Declare Function SetTimer Lib "user32" _
   (ByVal hwnd As Long, _
   ByVal nIDEvent As Long, _
   ByVal uElapse As Long, _
   ByVal lpTimerFunc As Long) As Long

Public Function UsingAddressOf() As Integer
   Dim TimerId As Long
   TimerId = SetTimer(0, 0, 500, AddressOf TestSub)
   UsingAddressOf = TimerId
End Function

Public Function TestSub(ByVal Message As String) As Boolean
   If Message <> "" Then
      MsgBox (Message)
      TestSub = True
   Else
      TestSub = False
   End If
End Function

C# Upgraded Code

private delegate bool Module1_TestSub_Delegate(string Message);
//UPGRADE_NOTE: (2041) The following line was commented.
//[DllImport("user32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
//extern public static int SetTimer(int hwnd, int nIDEvent, int uElapse, int lpTimerFunc);

internal static int UsingAddressOf()
{
    int TimerId = Project1Support.PInvoke.SafeNative.user32.SetTimer(0, 0, 500, (int) Marshal.GetFunctionPointerForDelegate((Module1_TestSub_Delegate) TestSub));
    return TimerId;
}

internal static bool TestSub(string Message)
{
    if (Message != "")
    {
        MessageBox.Show(Message, AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly()));
        return true;
    }
    else
    {
        return false;
    }
}

VB.NET Upgraded Code

Private Delegate Function Module1_TestSub_Delegate(ByVal Message As String) As Boolean
'UPGRADE_NOTE: (2041) The following line was commented.'
'Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Integer, ByVal nIDEvent As Integer, ByVal uElapse As Integer, ByVal lpTimerFunc As Integer) As Integer'

Public Function UsingAddressOf() As Integer
    Dim TimerId As Integer = Project1Support.SafeNative.user32.SetTimer(0, 0, 500, CInt(Marshal.GetFunctionPointerForDelegate(CType(AddressOf TestSub, Module1_TestSub_Delegate))))
    Return TimerId
End Function

Public Function TestSub(ByVal Message As String) As Boolean
    If Message <> "" Then
        MessageBox.Show(Message, My.Application.Info.Title)
        Return True
    Else
        Return False
    End If
End Function

6016 - Structure %1 should be within the shared file due to its use in Declare statement for a Windows API

Description

When migrating a solution made up of several projects, the use of shared files is common; in case a type is presented in that file, and one project uses this type as part of a native call (Windows API), and another project it is not; that type will exist in both, the PInvoke project and the shared file.

API Calls and structures are moved

The VBUC performs a refactoring of the API calls it encounters, along with types that can be used as parameters to those calls in new files. When that happens, the original VB6 Declare API statement is commented out. However, if there is another project that uses the same structure with no native calls in it, it must be kept in the code.

VB6 Original Code

Common/Module1.bas

Type RECTType
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Project1/MainForm.frm

Private Sub Form_Resize()
    Dim nRect As RECTType
    …
End Sub

Project2/dlls.bas

Option Explicit

Declare Function InvalidateRect Lib "user32" (ByVal hWnd As Long, lpRect As RECTType, ByVal bErase As Long) As Long

C# Upgraded Code

Common/Module1.cs

//UPGRADE_NOTE: (6016) Structure RECTType should be within the shared file due to its use in a Declare statement for a Windows API. More Information: https://docs.mobilize.net/vbuc/ewis#6016
[Serializable][StructLayout(LayoutKind.Sequential)]
public struct RECTType
{
	public int Left;
	public int Top;
	public int Right;
	public int Bottom;
}

Project1/MainForm.cs

private void Form_Resize(Object eventSender, EventArgs eventArgs)
{
	…
	Module1.RECTType nRect = new Module1.RECTType();	
	…
}

Project2/dlls.cs

//UPGRADE_NOTE: (2041) The following line was commented. More Information: https://docs.mobilize.net/vbuc/ewis#2041
////UPGRADE_TODO: (1050) Structure RECTType may require marshalling attributes to be passed as an argument in this Declare statement. More Information: https://docs.mobilize.net/vbuc/ewis#1050
//[DllImport("user32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
//extern public static int InvalidateRect(int hWnd, ref UpgradeSolution1Support.PInvoke.UnsafeNative.Structures.RECTType lpRect, int bErase);

UpgradeSolution1Support/PInvoke/UnsafeMethods/Structures.cs

[Serializable][StructLayout(LayoutKind.Sequential)]
public struct RECTType
{
	public int Left;
	public int Top;
	public int Right;
	public int Bottom;
}

C# Expected Code

The C# code contains two structs, one inside the shared file, the other one inside the PInvoke project. To maintain proper use of types, the type inside of the shared file can be removed or commented; and the uses of this type can be changed to the type inside the PInvoke project.

Common/Module1.cs

//[Serializable][StructLayout(LayoutKind.Sequential)]
//public struct RECTType
//{
//	public int Left;
//	public int Top;
//	public int Right;
//	public int Bottom;
//}

Project1/MainForm.cs

private void Form_Resize(Object eventSender, EventArgs eventArgs)
{
	…
	UpgradeSolution1Support.PInvoke.UnsafeNative.Structures.RECTType nRect = new UpgradeSolution1Support.PInvoke.UnsafeNative.Structures.RECTType();
	…
}

Project2/dlls.cs

//UPGRADE_NOTE: (2041) The following line was commented. More Information: https://docs.mobilize.net/vbuc/ewis#2041
////UPGRADE_TODO: (1050) Structure RECTType may require marshalling attributes to be passed as an argument in this Declare statement. More Information: https://docs.mobilize.net/vbuc/ewis#1050
//[DllImport("user32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
//extern public static int InvalidateRect(int hWnd, ref UpgradeSolution1Support.PInvoke.UnsafeNative.Structures.RECTType lpRect, int bErase);

UpgradeSolution1Support/PInvoke/UnsafeMethods/Structures.cs

[Serializable][StructLayout(LayoutKind.Sequential)]
public struct RECTType
{
	public int Left;
	public int Top;
	public int Right;
	public int Bottom;
}

VB.NET Upgraded Code

Common/Module1.vb

'UPGRADE_NOTE: (6016) Structure RECTType should be within the shared file due to its use in a Declare statement for a Windows API. More Information: https://docs.mobilize.net/vbuc/ewis#6016
<Serializable> _
<StructLayout(LayoutKind.Sequential)> _
 _
Structure RECTType
	Dim Left As Integer
	Dim Top As Integer
	Dim Right As Integer
	Dim Bottom As Integer
End Structure

Project1/MainForm.vb

Private Sub Form_Resize(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles MyBase.Resize
	…
	Dim nRect As New Module1.RECTType()
	…
End Sub

Project2/dlls.vb

'UPGRADE_NOTE: (2041) The following line was commented. More Information: https://docs.mobilize.net/vbuc/ewis#2041
''UPGRADE_TODO: (1050) Structure RECTType may require marshalling attributes to be passed as an argument in this Declare statement. More Information: https://docs.mobilize.net/vbuc/ewis#1050
'Declare Function InvalidateRect Lib "user32" (ByVal hWnd As Integer, ByRef lpRect As UpgradeSolution1Support.UnsafeNative.Structures.RECTType, ByVal bErase As Integer) As Integer

UpgradeSolution1Support/PInvoke/UnsafeMethods/Structures.vb

<Serializable> _
<StructLayout(LayoutKind.Sequential)> _
 _
Public Structure RECTType
	Dim Left As Integer
	Dim Top As Integer
	Dim Right As Integer
	Dim Bottom As Integer
End Structure

VB.NET Expected Code

The VB.NET code contains two structs, one inside the shared file, the other one inside the PInvoke project. To maintain proper use of types, the type inside of the shared file can be removed or commented; and the uses of this type can be changed to the type inside the PInvoke project.

Common/Module1.vb

'UPGRADE_NOTE: (6016) Structure RECTType should be within the shared file due to its use in a Declare statement for a Windows API. More Information: https://docs.mobilize.net/vbuc/ewis#6016
'<Serializable> _
'<StructLayout(LayoutKind.Sequential)> _
' _
'Structure RECTType
'	Dim Left As Integer
'	Dim Top As Integer
'	Dim Right As Integer
'	Dim Bottom As Integer
'End Structure

Project1/MainForm.vb

Private Sub Form_Resize(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles MyBase.Resize
	…
	Dim nRect As New UpgradeSolution1Support.UnsafeNative.Structures.RECTType()
	…
End Sub

Project2/dlls.vb

'UPGRADE_NOTE: (2041) The following line was commented. More Information: https://docs.mobilize.net/vbuc/ewis#2041
''UPGRADE_TODO: (1050) Structure RECTType may require marshalling attributes to be passed as an argument in this Declare statement. More Information: https://docs.mobilize.net/vbuc/ewis#1050
'Declare Function InvalidateRect Lib "user32" (ByVal hWnd As Integer, ByRef lpRect As UpgradeSolution1Support.UnsafeNative.Structures.RECTType, ByVal bErase As Integer) As Integer

UpgradeSolution1Support/PInvoke/UnsafeMethods/Structures.vb

<Serializable> _
<StructLayout(LayoutKind.Sequential)> _
 _
Public Structure RECTType
	Dim Left As Integer
	Dim Top As Integer
	Dim Right As Integer
	Dim Bottom As Integer
End Structure

6017 - Inaccessible enum value %1 was changed to its numerical value %2

Description

Since native declarations are moved to a separate support project, enums used as default values for optional parameters may not be accessible, and attempting to reference them could generate a circular reference.

To fix this issue, the enum element is replaced by its numerical value.

VB6 Original Code

Public Enum LOCAL_ENUM
        ...
        ENUM_VALUE = 5
	...
End Enum

Public Declare Function NativeCall Lib "nativelib.dll" Alias "NativeCallAlias" _
    (Optional ByVal opArg As LOCAL_ENUM = ENUM_VALUE) As Long

C# Upgraded Code

//UPGRADE_NOTE: (6017) Inaccessible enum value MyModule.LOCAL_ENUM.ENUM_VALUE was changed to its numerical value 5. More Information: https://docs.mobilize.net/vbuc/ewis/notes#id-6017
[DllImport("nativelib.dll", EntryPoint = "NativeCallAlias", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
extern public static int NativeCall(int opArg = 5);

VB.NET Upgraded Code

'UPGRADE_NOTE: (6017) Inaccessible enum value Module1.FREE_IMAGE_COLOR_CHANNEL.FICC_BLACK was changed to its numerical value 5. More Information: https://docs.mobilize.net/vbuc/ewis/notes#id-6017
Public Declare Function NativeCall Lib "nativelib"  Alias "NativeCallAlias"(Optional ByVal opArg As Integer = 5) As Integer

7001 - The following %1 (%2) seems to be dead code

Description

The VBUC analyzes the private subroutines and functions of each source code file, identifies the ones which are not used, and generates them commented out with this EWI preceding them. This improves the migration process by reducing the amount of manual work required to compile the application in .NET.

Recommendations

The target methods can be removed from the upgraded source code if they will not be used in the future. The code for these methods is upgraded but commented out. It is necessary to keep this code, it can be uncommented and used with the rest of the application.

This EWI is associated with the upgrade option Comment Out Dead Code. If it is turned off, unused code will not be commented on.

VB6 Original Code

Private Sub DeadCode()
    MsgBox "DeadCode"
End Sub

C# Upgraded Code

//UPGRADE_NOTE: (7001) The following declaration (DeadCode) seems to be dead code.
//private void DeadCode()
//{
    //MessageBox.Show("DeadCode", AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly()));
//}

VB.NET Upgraded Code

'UPGRADE_NOTE: (7001) The following declaration (DeadCode) seems to be dead code.'
'Private Sub DeadCode()'
    'MessageBox.Show("DeadCode", My.Application.Info.Title)'
'End Sub'

8001 - Element %1 was removed

Description

This message is displayed for several maps, when an element used in VB6 is obsolete in .NET or it is just no longer needed. This EWI is displayed if an assignment to a Property that will not be supported on the target is found because the target element is no longer available or the whole statement is commented out.

VB6 Original Code

Private Sub Form_Load()
   Dim text As String
   Dim SSPanel1 As ThreeD.SSPanel

   SSPanel1.Enabled = True

   SSPanel1.Caption = ""
End Sub

C# Upgraded Code

private void Form_Load()
{
    SSPanel.Panel SSPanel1 = null;

    SSPanel1.Enabled = true;

    //UPGRADE_NOTE: (8001) Element Set property was removed.
    //SSPanel1.Caption = "";
}

VB.NET Upgraded Code

Private Sub Form_Load()
    Dim SSPanel1 As SSPanel.Panel

    SSPanel1.Enabled = True

    'UPGRADE_NOTE: (8001) Element Set property was removed.'
    'SSPanel1.Caption = ""'
End Sub

8008 - Element %1 is obsolete and should be removed

Description

In this scenario, the element is no longer available on the target platform. However, it is part of a function call or expression and the statement cannot be removed without user revision. Therefore this note is issued so the user can take proper action.

This line will cause a compilation issue and must be corrected.

VB6 Original Code

Private Sub Form_Load()
    Dim text As String
    Dim SSPanel1 As ThreeD.SSPanel

    SSPanel1.Enabled = True

    SSPanel1.Caption = ""

    text = GetMessage(SSPanel1.Caption)

End Sub

Function GetMessage(text As String)
    GetMessage = "Caption is " & text
End Function

C# Upgraded Code

private void Form_Load()
{
    SSPanel.Panel SSPanel1 = null;

    SSPanel1.Enabled = true;

    //UPGRADE_NOTE: (8008) Element Caption is obsolete and should be removed.
    string text = GetMessage(SSPanel1.Caption)
}

//UPGRADE-WARNING: Parameter text was changed from byref to byval.
public string GetMessage(string text)
{
    return "Caption is " + text;
}

VB.NET Upgraded Code

Private Sub Form_Load()
    Dim SSPanel1 As SSPanel.Panel

    SSPanel1.Enabled = True

    'UPGRADE_NOTE: (8008) Element Caption is obsolete and should be removed.'
    Dim text_Renamed As String = GetMessage(SSPanel1.Caption)

End Sub

'UPGRADE-WARNING: Parameter text was changed from byref to byval.'
Function GetMessage(ByVal text_Renamed As String) As String
    Return "Caption is " & text_Renamed
End Function

See also:

Upgrade Projects with shared files
API Call Conversion to Platform Invoke
API Call Conversion to Platform Invoke