davito93
davito93

Reputation: 106

Custom User Control Throws Null Reference VB6 to VB.NET Migration

Had a problem using custom user controls in VB.Net after migrating a project from VB6. Just wanted to save someone some time by posting my solution since I did not see anything similar after searching.

Upvotes: 0

Views: 229

Answers (1)

davito93
davito93

Reputation: 106

The issue was if the User Control in VB6 used the UserControl_InitProperties() method, it does not get called automatically in VB.Net, therefore you need to call this method here:

 Public Sub New()
    MyBase.New()
    'This call is required by the Windows Form Designer.
    InitializeComponent()
    UserControl_Initialize()
    UserControl_InitProperties()
    End Sub

Upvotes: 1

Related Questions