I was hoping someone could help me with a bit of confusion surrounding the
'StrongNameIdentityPermissionAttribute' class.  I understand it and it works
perfectly if I use it in conjunction with Security.LinkDemand, i.e.
demanding for the permission at JIT time.  Here is an example:

<StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, _
PublicKey:="002400000480000094000...")> _
Public Class myClass
...

This works very well.  If I try to declare andinstantiate this from a
windows form I get a security exception.  If I compile the windows form app
with the correct key it works great.

My question deals with if I want to change to the 'SecurityAction' from
'LinkDemand' to 'Demand'.  Something like this:

<StrongNameIdentityPermissionAttribute(SecurityAction.Demand, _
PublicKey:="002400000480000094000...")> _
Public Class myClass
...


I guess my assumption was that if I used 'SecurityAction.Demand' the CLR
would walk up the stack and check the private key of all assemblies in the
stack and throw an exception if one didn't match.  This assumption is
obviously wrong.  Even my most basic application of a simple Winform
instantiating the class fails when I use 'Demand' rather than 'LinkDemand'.
I get the following error:

"Request for the permission of type
System.Security.Permissions.StrongNameIdentityPermission, mscorlib,
Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
failed."


Can someone explain why the 'LinkDemand' but not the 'Demand' works for the
same application?

Thanks in advance,

Dave.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to