Security Exception thrown from non-executed code? WHY WHY WHY???

K

Kelvin

Hi all,

This is very strange.

The ".Net Configuration" - "RunTime Security Policy" - "Permission
Sets" used by my smart client includes all the permissions (not full
trust).

In the code, I notice that the call "if(HttpContext.Current == null)"
always throws a Security exception.

Ok, fine, then I don't call it. BUT, the code would still throw an
exception even thought that line is not executed. For example:

int i=0;
if(i > 10) { // This block will never execute right?
if(HttpContext.Current == null) {
MessageBox.Show("It is null");
}
}

It still throws an exception at "HttpContext.Current == null"!

BUT if I put "if(HttpContext.Current == null)" into another method, it
works fine. For example:

int i=0;
if(i > 10) { // This would work!
if(CheckHttpContext()) {
MessageBox.Show("It is null");
}
}


public bool CheckHttpContext()
{
return HttpContext.Current == null;
}

Isn't it strange? By the way, does anyone know the different between
"Full Trust" and a Permission Sets that includes all the permission?

Thanks in advance!

Kelvin
 

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

Top