VB Migration Partner

KNOWLEDGE BASE - General


Previous | Index | Next 

[HOWTO] Determine if unsupported members throw an exception at runtime

Unsupported VB6 properties and methods – such as the DrawMode and ClipControls properties, the RichTextBox.SelPrint method, or the Toolbar.Change event – are marked as obsolete and can be scrutinized in Visual Studio’s Error List window. In addition, VB Migration Partner emits a remark that explains what happens if the property or method is invoked at runtime. In most cases, an unsupported property returns its default value and throws if a value other then the default value is assigned to it; similarly, an unsupported method throws an exception if it receives an argument that can’t be processed.

However, these runtime exceptions are turned off by default. This means that, for example, migrated .NET application behaves as if the DrawMode and ClipControls properties were never set, the RichTextBox.SelPrint method were never called, and the Toolbar.Change event were never raised. This arrangement enables the developer to test the migrated program without caring for such unsupported members.

In most cases, especially in the early stages of the migration process, this default behavior is OK. When you eventually have a working VB.NET or C# application, you might want to ensure that all minor details have been accounted for. To do so, you change the default behavior by adding the following statement in the .NET application:

        ' VB.NET 
        VB6Config.ThrowOnUnsupportedMembers = True

        // C# 
        VB6Config.ThrowOnUnsupportedMembers = True;

When the VB6Config.ThrowOnUnsupportedMembers property is set to True, calling an unsupported method or setting a property to an unsupported value throws an exception. Instead of modifying the migrated VB.NET code, you can set this option automatically by adding an appropriate InsertStatement pragma in the original VB6 code:

        Sub Main()
           
         '##InsertStatement VB6Config.ThrowOnUnsupportedMembers = True
         ' ...
        End Sub
Previous | Index | Next 




Follow Francesco Balena on VB6 migration’s group on

LinkedIn





Read Microsoft Corp’s official case study of a VB6 conversion using VB Migration Partner.




Code Architects and its partners offers remote and onsite migration services.

More details




Subscribe to our free newsletter for useful VB6 migration tips and techniques.

newsletter



To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. You will receive a detailed report about your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.

Get free advice



A fully-working, time-limited Trial Edition of VB Migration Partner allows you to test it against your actual code

Get the Trial




The price of VB Migration Partner depends on the size of the VB6 application, the type of license, and other factors

Request a quote




Migrating a VB6 application in 10 easy steps

Comparing VB Migration Partner with Upgrade Wizard

Migration tools: Feature Comparison Table

All whitepapers