InteropToolBox.Globals does not retrieve value when using VS2010 and .Net Framework 4

已锁定 InteropToolBox.Globals does not retrieve value when using VS2010 and .Net Framework 4

  • 2011年1月13日 23:41
     
     
    I have a .net usercontrol which works properly with .net framework 3.5 or earlier, ie., I can add a key to the InteropToolBox. Globals collection and retrieve it in .Net as expected.  When I use .Net Framework 4.0 to build the usercontrol, and perform the same test, it returns null for the key value.  Using Interop Toolkit 2.1, VS2010, VB6.0(SP5) 
    Larry W

全部回复

  • 2011年1月17日 6:34
    版主
     
     

    Hello wadelww,

    Thanks for your post.

    Based on your description, it seems difficult to find the root cause. Would you mind providing the project code? 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.

  • 2011年1月17日 16:15
     
     
    In order to reproduce the problem you need both projects (VS2010 and VB6).  I don't know how to upload those projects.
    Larry W
  • 2011年1月18日 6:37
    版主
     
     

    Hello wadelww,

    You could unload the project code to your SkyDrive and share the link to us. If so, we could download from our side. If you don't want to share, you could send to this email v-lilite@microsoft.com.

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

    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.

  • 2011年1月21日 10:17
    版主
     
     

    Hello wadelww,

    I am writing to check the status of the issue on your side. What's the situation on your side? Would you mind sharing the project code? If you need further assistance, 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.

  • 2011年4月8日 13:17
     
     

    I am having the same issue. If the target framework is 3.5 then I am able to retrieve the global variable being passed from VB6. If the target framework is 4.0, the value is null.

     

    This is using the Interops Forms Toolkit 2.1 and Visual Studio 2010


    -----------

    Vb6
    ---------- 
    Call g_InteropToolbox.Globals.Add("key", "test")

     

    ----------
    .NET
    ----------
    Dim xl as String = 
    My.InteropToolbox.Globals.Item("key")

  • 2011年5月5日 15:46
     
     

    Hi i have the same problem, when i try to close DotNet forms from the vb6 form Close event.

     

    Some tip? i need help!!!!

     

    thanks in advanced

     

  • 2011年12月10日 19:09
     
      包含代码

    Hi Liliane,

     

    I'm using VS2010 and Formsinterop 2.1 and I dont seem to be able to raise events or pass on global values to the .NET library.

    I didnt tried with VS2008 yet.

    What I did was simple.

    In VB6 I've writen thes code on a class:

    Public g_InteropToolbox As InteropToolbox

    Private WithEvents g_InteropMessenger As InteropEventMessenger

    Public Sub Startup() ' This is called on app atsratup on my vb project

        Set g_InteropToolbox = New InteropToolbox
        Set g_InteropMessenger = g_InteropToolbox.EventMessenger
        g_InteropToolbox.Initialize
        g_InteropMessenger.RaiseApplicationStartedupEvent
               
        
        g_InteropToolbox.Globals.Add "UserName", "bla"
        g_InteropToolbox.Globals.Add "Password", "something"
        g_InteropToolbox.Globals.Add "ServerName", "localhost"
        g_InteropToolbox.Globals.Add "DatabaseName", "DB"
       
        g_InteropMessenger.RaiseApplicationEvent "ConnectionInfo", ""
       
    End Sub

    On .NET project I've edited the ActiveXControlHelpers.vb file on the My section:

    Namespace My
        'The HideModuleNameAttribute hides the module name MyInteropToolbox so the syntax becomes My.InteropToolbox.   
        <Global.Microsoft.VisualBasic.HideModuleName()> _
        Module MyInteropToolbox
     
            Private _toolbox As New InteropToolbox
            Public WithEvents _mesenger As InteropEventMessenger = _toolbox.EventMessenger
            Public ReadOnly Property InteropToolbox() As InteropToolbox
                Get
                    Return _toolbox
                End Get
            End Property
     
            Private Sub HandleAppEvents(ByVal type As StringByVal params As ObjectHandles _mesenger.ApplicationEventRaised
                If type = "ConnectionInfo" Then
                    ' Its not raisen
                End If         End Sub         Private Sub _mesenger_ApplicationStartedup() Handles _mesenger.ApplicationStartedup              ' Its not raisen
            End Sub     End Module End Namespace

     

     And:

    My.InteropToolbox.Globals.Item("UserName")
    

     Is allways empty.

     

    Any tips?

     


    Please remember to mark the replies as answers if they help you.