Invalid Cast Exception on Context.ApplicationInstance

Discussion in 'ASP .Net' started by Mark Olbert, Dec 4, 2003.

  1. Mark Olbert

    Mark Olbert Guest

    I have a v1.1 webapp that works fine on two different servers (my development machine and a
    Verio-hosted site). However, it blows up on a MaximumASP-hosted site at a particular line:

    private void Page_Load(object sender, System.EventArgs e)
    {
    // snippet
    theGlobal = (Global) Context.ApplicationInstance;
    }

    I put a bunch of site-wide methods and properties in the Global.asax file and reference them through
    this cast.

    Does anyone have any idea why this would work in some environments and not others?

    Thanx in advance for any help or advice.

    - Mark
    Mark Olbert, Dec 4, 2003
    #1
    1. Advertising

  2. Hi Mark,

    Thank you for posting to the MSDN newsgroups.

    Please use "((global_asax)Context.ApplicationInstance)" and test this issue
    again.

    I hope it helps.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jacob Yang [MSFT], Dec 5, 2003
    #2
    1. Advertising

  3. Mark Olbert

    Mark Olbert Guest

    Jacob,

    Actually, the answer was even simpler: I'd forgotten to upload the global.asax file after I'd
    customized it's code-behind. The cast was failing because, without global.asax,
    Context.ApplicationInstance is an HttpApplication, but with global.asax present it's a Global.

    - Mark

    On Fri, 05 Dec 2003 01:53:10 GMT, (Jacob Yang [MSFT]) wrote:

    >Hi Mark,
    >
    >Thank you for posting to the MSDN newsgroups.
    >
    >Please use "((global_asax)Context.ApplicationInstance)" and test this issue
    >again.
    >
    >I hope it helps.
    >
    >Best regards,
    >
    >Jacob Yang
    >Microsoft Online Partner Support
    >Get Secure! ¨C www.microsoft.com/security
    >This posting is provided "as is" with no warranties and confers no rights.
    Mark Olbert, Dec 5, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer

    Question: Invalid Cast Exception Error

    VB Programmer, Oct 28, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    1,340
    VB Programmer
    Oct 28, 2003
  2. Nick Flandry
    Replies:
    5
    Views:
    432
    Michael Graham[MSFT]
    Feb 12, 2004
  3. buzz
    Replies:
    9
    Views:
    486
    Scott Allen
    Mar 19, 2005
  4. Wayne Brantley

    hides inherited member ApplicationInstance

    Wayne Brantley, Dec 15, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    6,896
    Steven Cheng[MSFT]
    Dec 19, 2005
  5. Nigil LaVey

    Getting the ApplicationInstance in webcontrol? Help

    Nigil LaVey, Jun 13, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    123
    Brock Allen
    Jun 13, 2005
Loading...

Share This Page