Home All Groups Group Topic Archive Search About
Author
18 Jul 2005 2:43 PM
Bob
I am not sure why one should use the Demand() method?  Wouldn't the attempt
to access the resource thrown the same security exception? For example does
the below Demand() actually help in any way?

SocketPermission socketPermission = new
SocketPermission(System.Net.NetworkAccess.Connect,System.Net.TransportType.Tcp,Server,Port);
socketPermission.Demand();

ipepServer = new IPEndPoint(IPAddress.Parse(Server),nPort);
Socket s = new Socket();
s. Connect(ipepServer);

Bob

Author
18 Jul 2005 3:32 PM
ep
it would, but you may have a situation where you want to demand permissions
before you do more work.
So if you have a lot more work to do, or perhaps you have multiple
permissions that you want to check before you do anything, check them first
and save yourself CPU time and cleanup if permission failed.




"Bob" <msg***@hotmail.com> wrote in message
news:%23gfODc6iFHA.3300@TK2MSFTNGP15.phx.gbl...
> I am not sure why one should use the Demand() method?  Wouldn't the
attempt
> to access the resource thrown the same security exception? For example
does
> the below Demand() actually help in any way?
>
> SocketPermission socketPermission = new
>
SocketPermission(System.Net.NetworkAccess.Connect,System.Net.TransportType.T
cp,Server,Port);
Show quoteHide quote
> socketPermission.Demand();
>
> ipepServer = new IPEndPoint(IPAddress.Parse(Server),nPort);
> Socket s = new Socket();
> s. Connect(ipepServer);
>
> Bob
>
>