Problem: Cannot Successfully Reference "SessionUtility" from VS 2008 (Trying to Implement "How to Share Session State Between Classic ASP and ASP.NET")

Last post 11-13-2009 3:45 PM by ps2goat. 5 replies.

Sort Posts:

  • Problem: Cannot Successfully Reference "SessionUtility" from VS 2008 (Trying to Implement "How to Share Session State Between Classic ASP and ASP.NET")

    11-10-2009, 10:34 AM
    • Member
      1 point Member
    • tkates1aspnet
    • Member since 11-10-2009, 2:26 PM
    • Lehigh Valley, PA
    • Posts 3

    I'm trying to implement the MSDN "How to Share Session State Between Classic ASP and ASP.NET."

    I haven't been able to correctly setup the reference to the SessionUtility.dll file from within VS 2008. 

    I successfully installed the SessionUtility.dll into the GAC.
    (C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\gacutil.exe /i SessionUtility.dll.)
    Note the v1.1.4322 version there.  I could not find a gacutil.exe on my machine for v2.0 or v3.5.

    I successfully exposed the SessionUtility.dll as a COM object using the regasm.exe.
    (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe SessionUtility.dll /tlb:SessionUtility.tlb).

    I successfully loaded the Classic ASP page "TestPage.asp" and saw the expected number "1" on the web page.

    I then ran the ASPX page "TestPage.aspx" and received the error: "Could not load type 'MSDN.SessionPage'."  I realized that I forgot to make a reference to the SessionUtility.dll in VS 2008 so I went to the "COM" tab in the "Add Reference" dialog, and selected "SessionUtility" (which is pointing to SessionUtility.tlb.)

    When I click the "OK" button to add the reference, I get this error...

    A reference to 'SessionUtility' could not be added. Converting the type library to a .NET assembly failed.  Type library 'SessionUtility' was exported from a CLR assembly and cannot be re-imported as a CLR assembly.

    I did some searching and found a post or two saying that I should choose "SessionUtility" from the ".NET" tab in the "Add References" dialog box, not from the "COM" tab, but it is not listed on the ".NET" tab.

    What did I do wrong?  What am I missing?

     

  • Re: Problem: Cannot Successfully Reference "SessionUtility" from VS 2008 (Trying to Implement "How to Share Session State Between Classic ASP and ASP.NET")

    11-10-2009, 8:18 PM
    • Star
      10,691 point Star
    • ps2goat
    • Member since 11-17-2006, 5:43 PM
    • Posts 1,951

    When you install Visual studio 2005 and/or 2008, you should have a list of tools that came with it, including gacutil.  To make it easier to find, navigate to the proper version of Visual Studio from your Start menu, and select the proper command line tool.

    For example, with 2005, Start-> All Programs -> Microsoft Visual Studio 2005 -> Visual Studio Tools -> Visual Studio 2005 Command Prompt.

    Using that version of the command prompt will instantly register the location of your installed VS Tools, so all you have to type in is "gacutil" with whatever switches you need.  No need to specify the directory of the tools.

    Once you register the DLL with the GAC, it should appear under the ".NET" tab when adding a reference.  If not, close all open instances of Visual Studio and then re-try.

    ---------------------------------------
    MCP - Web Based Client Development .NET 2.0
  • Re: Problem: Cannot Successfully Reference "SessionUtility" from VS 2008 (Trying to Implement "How to Share Session State Between Classic ASP and ASP.NET")

    11-11-2009, 8:38 AM
    • Member
      1 point Member
    • tkates1aspnet
    • Member since 11-10-2009, 2:26 PM
    • Lehigh Valley, PA
    • Posts 3

    Thanks for your feedback ps2goat.

    OK...

    • Found the VS command prompt 
    • Registered the DLL (gacutil /i C:\Downloads\AspDotNetSessionSharing\SessionSample\Demo\SessionUtility.dll)
    • Restarted VS
    • Opened my project
    • Still cannot find the DLL under the ".NET" tab (I'm assuming it should either appear as "MSDN.SessionUtility" or "SessionUtility")

    Then I figured that maybe what I did before (registering it with the v1.x gacutil) was interfering with it in some way.  So I went back to the VS command prompt and ran...

    • gacutil /u SessionUtility
    • Checked the "COM" tab to see if the reference to SessionUtility was still there.  It was so I then ran...
    • regasm.exe C:\Downloads\AspDotNetSessionSharing\SessionSample\Demo\SessionUtility.dll /unregister /tlb:SessionUtility.tlb
    • Restarted VS
    • Verified the reference to SessionUtility was NOT there.  It wasn't.  Then ran...
    • gacutil /i C:\Downloads\AspDotNetSessionSharing\SessionSample\Demo\SessionUtility.dll
    • regasm.exe C:\Downloads\AspDotNetSessionSharing\SessionSample\Demo\SessionUtility.dll /tlb:C:\Downloads\AspDotNetSessionSharing\SessionSample\Demo\SessionUtility.tlb
    • Restarted VS
    • Checked the ".NET" tab.  No references to SessionUtility there.
    • Checked the "COM" tab.  The reference to SessionUtility was there.

    So it's still not showing up on the ".NET" tab.

    Do you think I would need to also unregister SessionUtility.dll with the v1.x gacutil (since I originally registered it that way)?

    I shouldn't need to unregister and reregister the SessionManager.dll should I?  That shouldn't have any bearing on the SessionUtility.dll, should it?

    Do you have any other ideas?

    Filed under: , , ,
  • Re: Problem: Cannot Successfully Reference "SessionUtility" from VS 2008 (Trying to Implement "How to Share Session State Between Classic ASP and ASP.NET")

    11-11-2009, 5:02 PM
    Answer
    • Star
      10,691 point Star
    • ps2goat
    • Member since 11-17-2006, 5:43 PM
    • Posts 1,951

     You can verify that the DLL was registered properly.  Control Panel-> Administrative Tools -> .NET Framework 2.0 Configuration.

    In the left panel, expand 'my computer', then click 'Assembly Cache'. Now, in the right pane, click 'View list of Assemblies in the Assembly Cache'.  Review that and see if the DLL you registered is in there.  It may show up under a different name, because the GAC view is based on the namespace of the DLL.

     

    You can also try to choose the 'Projects' tab when adding a reference, and see if it allows you to select the DLL that way (choose 'Browse' and navigate to the file).

    ---------------------------------------
    MCP - Web Based Client Development .NET 2.0
  • Re: Problem: Cannot Successfully Reference "SessionUtility" from VS 2008 (Trying to Implement "How to Share Session State Between Classic ASP and ASP.NET")

    11-13-2009, 9:37 AM
    • Member
      1 point Member
    • tkates1aspnet
    • Member since 11-10-2009, 2:26 PM
    • Lehigh Valley, PA
    • Posts 3

    It's working!  Thanks!  One more quick question (below.)

    There was no "Browse" option when I clicked on the "Projects" tab, but there is a separate "Browse" tab.  I browsed to the DLL and selected it from there.  Then is started working.

    I do not have a ".NET Framework 2.0 Configuration" option in Control Panel-> Administrative Tools.  I do have ".NET Framework Configuration" which points to a v1.0 .msc file and a ".NET Framework 1.1 Configuration" option.

    Any idea why I wouldn't have the "2.0" configuration option?
    (from the VS "About" dialog...I'm using VS 2008 v9.0.30729.1SP and MS .NET Framework v3.5 SP1)

    Filed under: , , ,
  • Re: Problem: Cannot Successfully Reference "SessionUtility" from VS 2008 (Trying to Implement "How to Share Session State Between Classic ASP and ASP.NET")

    11-13-2009, 3:45 PM
    • Star
      10,691 point Star
    • ps2goat
    • Member since 11-17-2006, 5:43 PM
    • Posts 1,951

    tkates1aspnet:
    There was no "Browse" option when I clicked on the "Projects" tab, but there is a separate "Browse" tab.
     

    Sorry, I tried to do that part from memory; something programmers shouldn't do!

     

    tkates1aspnet:
    Any idea why I wouldn't have the "2.0" configuration option?

    Not really, unless you are using either VS Standard or Express (free version).  I'm using Professional.  Maybe the tools weren't installed.

    Microsoft does say that the configuration tool was included in .NET 1.x redistributable, but it is (was?) only available for 2.0 (and above extensions) if the .NET 2.0 SDK is installed.  Thus, if you are installing on a server where Visual Studio is not installed, you will not see the tool.

    If you have hidden files and folders turned on, you can still view GAC DLLs by going to %windir%\assembly, where %windir% is your windows directory, defaulting to C:\Windows.

    ---------------------------------------
    MCP - Web Based Client Development .NET 2.0
Page 1 of 1 (6 items)