Invalid Cast Exception on Context.ApplicationInstance

  • Thread starter Thread starter Mark Olbert
  • Start date Start date
M

Mark Olbert

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
 
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,

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
 
Back
Top