Charlie Posted February 20, 2020 Report Share Posted February 20, 2020 VBUC is converting a control to a dynamic type: VBUC code: Private cvctlAuditControl As Control Private Sub UpdateBoundControls(ByVal pvobjContext As IContext) If Not cvctlAuditControl Is Nothing Then If cvbooInsertInProgress Then cvctlAuditControl = "" ..... End Sub C# converted code: private dynamic cvctlAuditControl = null; private void UpdateBoundControls(INTBSSystem.IContext pvobjContext) { if (cvctlAuditControl != null) { if (cvbooInsertInProgress) { //NotUpgradedHelper.NotifyNotUpgradedElement("The following assignment/return was commented because it has incompatible types"); //UPGRADE_WARNING: (1068) cvctlAuditControl of type VB.Control is being forced to Scalar. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068 cvctlAuditControl = ""; .... We could solve our problems by doing this little change: private dynamic cvctlAuditControl = null; private void UpdateBoundControls(INTBSSystem.IContext pvobjContext) { if (cvctlAuditControl != null) { if (cvbooInsertInProgress) { //NotUpgradedHelper.NotifyNotUpgradedElement("The following assignment/return was commented because it has incompatible types"); //UPGRADE_WARNING: (1068) cvctlAuditControl of type VB.Control is being forced to Scalar. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068 cvctlAuditControl.Text = ""; The problem is we have to do it manually, and we are not sure how many of this cases we have in our code. Is there a better way to solve this issue? Regards. Link to comment Share on other sites More sharing options...
Mobilize.Net Staff OlmanQuesada Posted February 20, 2020 Mobilize.Net Staff Report Share Posted February 20, 2020 Hi Charlie, You can solve this situation by re-migrating the code by modifying the Migration Options to use Mobilize helper classes to deal with Default Properties and Late Binding Objects, as shown in the image below. C# does not support Default Properties, so statements like cvctlAuditControl = "" in .NET will need to specify the property for the object in cvctlAuditControl to set with an empty string. The VBUC provides a mechanism to help on this: The Reflection Helper. This helper class contains a collection of .NET classes and their respective Default Property. The following sample shows how it works: VB6: Private Sub Form_Load() foo Me.Text1 foo Me.Label1 End Sub Sub foo(ctl As Control) If Not ctl Is Nothing Then ctl = "my text" End If End Sub C# public void foo(ref Control ctl) { if (ctl != null) { //UPGRADE_WARNING: (1068) ctl of type VB.Control is being forced to Scalar. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1068 ReflectionHelper.SetPrimitiveValue(ctl, "my text"); } } The Upgrade Warning 1068 indicates there's a situation, in this case caused due to a Default property in VB6. The ReflectionHelper.SetPrimitiveValue extract the datatype of the ctl object and then look for the associated Default Property (if any) to assign the "my text" value to that property. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now