- INDEX VB TO NET
- KNOWLEDGE BASE
- EWIS-ISSUES
- ISSUE #6002
WARNING #6002
UserControl Event 1% is not supported.
Description
Using the VBUC, ActiveX controls can be migrated to .NETWindows Controls. This can present a problem when migrating certain ActiveX User Controls that implement Events that are no longer supported in .NET. In most cases, this is because they do not have an exact equivalent in .NET.
Recommendations
An understanding of both the source platform and the target platform is helpful in coming up with a viable solution. Some of this is described in MSDN's User Controls for Visual Basic 6.0 Users.
Visual Basic 6.0 Support
Resources for those unfamiliar with Visual Basic 6.0 ActiveX Controls:
- Creating an ActiveX Control - a basic tutorial from which the sample VB6 code was taken.
- UserControl properties - on UserControl's built-in properties.
- Life and Times of a UserControl Object - on the events and lifecycle of a UserControl.
- Understanding Control Lifetime and Key Events
- Extender Object - for an overview of the Extender object.
.Net Framework Support
Source VB6
Private Sub UserControl_WriteProperties(PropBag As PropertyBag) Debug.Print "WriteProperties" PropBag.WriteProperty "Caption", Caption, Extender.Name End Sub
Target VB.NET
'UPGRADE_ISSUE: (2068) PropertyBag object was not upgraded. 'UPGRADE_WARNING: (6002) UserControl Event WriteProperties is not supported. Private Sub UserControl_WriteProperties(ByVal PropBag As UpgradeSolution1Support.UpgradeStubs.PropertyBag) Debug.WriteLine("WriteProperties") 'UPGRADE_ISSUE: (2064) UserControl property UserControl1.Extender was not upgraded. 'UPGRADE_ISSUE: (2064) PropertyBag method PropBag.WriteProperty was not upgraded. PropBag.WriteProperty("Caption", Text, Me.getExtender().Name) End Sub
Target C#
//UPGRADE_ISSUE: (2068) PropertyBag object was not upgraded. //UPGRADE_WARNING: (6002) UserControl Event WriteProperties is not supported. private void UserControl_WriteProperties(UpgradeStubs.PropertyBag PropBag) { Debug.WriteLine("WriteProperties"); //UPGRADE_ISSUE: (2064) UserControl property UserControl1.Extender was not upgraded. //UPGRADE_ISSUE: (2064) PropertyBag method PropBag.WriteProperty was not upgraded. PropBag.WriteProperty("Caption", Convert.ToString(Caption), this.getExtender().Name); }
This solution makes use of Application Settings to replace Visual Basic 6's PropertyBag. In most cases this is not necessary as .NET's design model maintains the state of properties without the use of the Settings object. This example assumes that these values need to be preserved between instances of the program.
private void UserControl_WriteProperties() { Debug.WriteLine("WriteProperties"); Properties.Settings.Default.Caption = this.Name; }