Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. A problem about STA object that is stored in Session State

A problem about STA object that is stored in Session State

Scheduled Pinned Locked Moved ASP.NET
csharpquestionasp-nethelp
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zengkun
    wrote on last edited by
    #1

    Hi! First,I write a class with C#.The class looks like this class CSharpClass { //class_imported_from_typelibrary is a coclass that imported from //the typelibrary using Tlbimp.exe //all interfaces of this coclass are derived from IUnknown class_imported_from_typelibrary m_comclass; //CSharpClassA and CSharpClassB are two classes written in C# CSharpClassA m_a; CSharpClassB m_b; …… …… } I use this CSharpClass in my ASP.NET project later.The code in Page_Load function looks like this: Page_Load() { private CSharpClass m_SharpClass; if(Session["MyObj"] == null) { m_SharpClass = new csharpclass(); m_SharpClass.Dosomething(); Session["MyObj"] = m_SharpClass } else { m_SharpClass = (csharpclass)Session["MyObj"]; m_SharpClass.Dosomething(); } } After I retrieve the m_SharpClass from Session state,using this statement(m_SharpClass = (csharpclass)Session["MyObj"]).I found that the two fields m_a and m_b in the m_SharpClass object are OK,but m_comclass is corrupted,from the "Watch Window" it's value is an InvalidCastException.I don't know why? How can I gain access to the STA object after store it in the Session State later? I have set the AspCompat attribute to true. Thank you for your reply!;P

    Z 1 Reply Last reply
    0
    • Z zengkun

      Hi! First,I write a class with C#.The class looks like this class CSharpClass { //class_imported_from_typelibrary is a coclass that imported from //the typelibrary using Tlbimp.exe //all interfaces of this coclass are derived from IUnknown class_imported_from_typelibrary m_comclass; //CSharpClassA and CSharpClassB are two classes written in C# CSharpClassA m_a; CSharpClassB m_b; …… …… } I use this CSharpClass in my ASP.NET project later.The code in Page_Load function looks like this: Page_Load() { private CSharpClass m_SharpClass; if(Session["MyObj"] == null) { m_SharpClass = new csharpclass(); m_SharpClass.Dosomething(); Session["MyObj"] = m_SharpClass } else { m_SharpClass = (csharpclass)Session["MyObj"]; m_SharpClass.Dosomething(); } } After I retrieve the m_SharpClass from Session state,using this statement(m_SharpClass = (csharpclass)Session["MyObj"]).I found that the two fields m_a and m_b in the m_SharpClass object are OK,but m_comclass is corrupted,from the "Watch Window" it's value is an InvalidCastException.I don't know why? How can I gain access to the STA object after store it in the Session State later? I have set the AspCompat attribute to true. Thank you for your reply!;P

      Z Offline
      Z Offline
      zengkun
      wrote on last edited by
      #2

      It seems that this problem has been resolved. After I setup the service pack for .net framework version 1.1,everything thing seems Okay. Thanks! Enjoy!:laugh:

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups