Invalid Cast Exception on Context.ApplicationInstance

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
 
J

Jacob Yang [MSFT]

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.
 
M

Mark Olbert

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top