Home All Groups Group Topic Archive Search About

full trus and 1.1 SP1

Author
18 Mar 2005 6:17 PM
AndrewEames
I just applied 1.1 SP1 and I am seeing some changes in behavior wrt. security

If I set my security level to no trust, my .NET application will now actualy
execute until Application.Run (previously, it wouldn't even start up without
execute permission)

So great I thought - I can put up a friendly dialog for my users if I dont
have full trust. so I added the following code

      PermissionSet fullTrust = new
PermissionSet(PermissionState.Unrestricted);
      try
      {
        fullTrust.Demand();
      }
      catch(SecurityException)
      {

However, this demand succeeds even if I am running under no trust - why is
this?
  Thanks
      Andrew

Author
18 Mar 2005 8:58 PM
Nicole Calinoiu
"AndrewEames" <AndrewEa***@discussions.microsoft.com> wrote in message
news:B5DEB5D5-E5DB-4D4F-9F22-31AE8438A147@microsoft.com...
>I just applied 1.1 SP1 and I am seeing some changes in behavior wrt.
>security
>
> If I set my security level to no trust, my .NET application will now
> actualy
> execute until Application.Run (previously, it wouldn't even start up
> without
> execute permission)

This seems rather unlikely.  It might be a good idea to confirm whether your
application is truly being granted no permissions at all
(http://support.microsoft.com/kb/815170/EN-US/).  If it really isn't being
granted SecurityPermission\Execution, could you please post short but
complete sample code (http://www.yoda.arachsys.com/csharp/complete.html) for
an application that demonstrates this?


Show quote
> So great I thought - I can put up a friendly dialog for my users if I dont
> have full trust. so I added the following code
>
>      PermissionSet fullTrust = new
> PermissionSet(PermissionState.Unrestricted);
>      try
>      {
>        fullTrust.Demand();
>      }
>      catch(SecurityException)
>      {
>
> However, this demand succeeds even if I am running under no trust - why is
> this?

Probably because the demand applies only to callers, but not to the method
in which it is used.  Try moving the demand into a separate method called
from within your Main method.


Show quote
>  Thanks
>      Andrew
>
>

AddThis Social Bookmark Button