Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / October 2004

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kelvin - 13 Oct 2004 17:58 GMT
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
Sijin Joseph - 14 Oct 2004 04:54 GMT
What i think may be happening is that the security check is being
performed before the method gets JIT compiled so in that case it will be
scanned for security exceptions before the JIT compilation begins for
the method.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

> Hi all,
>
[quoted text clipped - 40 lines]
>
> Kelvin

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.