locked
Sharing Application State in a Hybrid Application broken in .NET 4.0

    Question

  • The InteropForms Toolkit supports global values that can be added and removed to the InteropToolbox.Globals collection.

    This feature works in .NET 3.5 but when using the same feature in .NET 4.0, the values are null when retrieving them on the .NET side.

    Using InteropForms Toolkit 2.1, Visual Studio 2010 and Visual Basic 6(SP6)


    *** Set value in the Globals collection from Visual Basic 6 code ***

    •  Call g_InteropToolbox.Globals.Add("company", "Microsoft")

     

    *** Retrieve value from Globals collection within a .NET InteropForm ***

    • Dim m_company as String = My.InteropToolbox.Globals.Item("company")

     

    If I change the target framework of the application to 3.5, the item is present. When the target framework is changed to 4.0, the item is always null. To be exact, the key is not added to the collection. Strange enough, if I add a value to the collection from .NET and try to retrieve it on the Visual Basic 6 side, it is present.

     

     

    Thanks

    Miguel

    Saturday, August 13, 2011 6:46 PM

All replies

  • Hello Miguel,

    Thanks for your post.

    Does the usercontrol works properly in 4.0? How do you set the value to the Globals collection? Could you please provide a simple project code which could identified the scenario on your side? If so, we could reproduce the issue on our side.

    Best regards


    Liliane Teng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, August 15, 2011 9:57 AM
  • Hello Liliane

    Thanks for your reply.

    I have sent a small sample of the code to your email

    In case the email does not go through, below is what I am doing in the code:

    The VB6 project has a form with a textbox and a button. When you press the button, I add the value of the textbox into the global collection and call the .NET Hybrid Form

    • ' Set value in the Globals collection
         g_InteropToolbox.Globals.Add "Company", txtCompany.Text
    • ' Open .NET form
          Dim HybridForm As New DotNetHybridForm
          HybridForm.Show

     

    When I open the .NET Hybrid form, I access the global collection and retrieve the key I added on the VB6 side and display it on a label

    • ' Get value from globals collection
      Dim token as string = My.InteropToolbox.Globals("Company")
      If token IsNot Nothing Then
            lblValue.Text = token
      End If

    If the target framework of the .NET application is 3.5, the global value is present. If I change the target framework of the application to 4.0, the value does not make it across even though the value is still visible on the VB6 side.

    Thanks

    Miguel

    Wednesday, August 17, 2011 1:28 PM
  • Hi Miguel,

    I received your email and the sample code. I could reproduce the scenario on my side now. I am doing research on this issue. There might be some delay about response. Appreciate your patience.

    Have a nice day.

    Best regards


    Liliane Teng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

     

    Thursday, August 18, 2011 10:39 AM
  • Hi Miguel,

    When you build with .NET Framework 3.5, the references' version are 2.0.0.0. When you build with .NET Framwrok 4.0, the references' version are 4.0.0.0. Although the Interop Forms Toolkit 2.1 supports CLR 4.0, but the feature support of the toolkit 2.1 remains supports .NET framework 2.0.

    More information, please check:

    http://msdn.microsoft.com/en-us/vbasic/bb419144.aspx
    Interop Forms Toolkit 2.1

    New in Version 2.1
    With this release, the setup authoring was updated so that the toolkit supports Visual Studio 2005, Visual Studio 2008 and Visual Studio 2010.
    The feature support of the toolkit remains unchanged from v2.0. The toolkit still supports adding controls, methods, properties, and events to Visual Basic 6 applications using Visual Basic.NET. The documentation, assemblies, redistributable, and toolkit use also remains unchanged.

    Build with .NET Framework 4.0:

    Build with .NET Framework 3.5:

    If you have any concerns, please feel free to follow up.

    Have a nice day.

    Best regards


    Liliane Teng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Liliane Teng Thursday, August 25, 2011 6:13 AM
    • Unmarked as answer by Grullon, Miguel Monday, August 29, 2011 2:53 PM
    Friday, August 19, 2011 5:34 AM
  • Hi Miguel,

    Would you mind letting us know the result of the suggestions? If you have any concerns, please feel free to follow up.

    Have a nice day.

    Best regards


    Liliane Teng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, August 22, 2011 3:17 AM
  • Liliane

    Thanks for your response.

    That means I cannot use the InteropToolbox.Globals collection when using the InteropForms Toolkit 2.1 in .NET 4.0 and in order to do so must change the target framework to 3.5

    If so, when will this feature be fixed or implemented?

    Thanks

    Miguel

    Monday, August 29, 2011 2:53 PM
  • Hi Miguel,

    Yes. But I am not sure when this feature will be implemented. You could consider submitting this issue to Microsoft Connect feedback portal http://connect.microsoft.com/ . Microsoft engineers will evaluate it seriously. Thanks for your feedback.

    Have a nice day.

    Best regards


    Liliane Teng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, August 30, 2011 3:47 AM