Re: fxcop and link demands
- From: "Nicole Calinoiu" <calinoiu REMOVETHIS AT gmail DOT com>
- Date: Wed, 15 Feb 2006 15:55:44 -0500
"AMercer" <AMercer@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:442B0902-A798-4BC5-ADEF-FEDD82F32368@xxxxxxxxxxxxxxxx
When I run fxcop against my vb app (MyApp, FW 1.1, a vb winforms program),
I
get some complaints about LinkDemands, namely:
"Do not indirectly expose methods with link demands"
What am I supposed to do about this?
In general, one would want to protect any members that expose those target
methods with link demands or full demands for the same permissions specified
in the original link demand. This will ensure that your code can't satisfy
a link demand on behalf of a less privileged caller without forcing the
caller to pass a demand for the same permission.
I tried putting
<Permission(Permissions.SecurityAction.LinkDemand, UnmanagedCode:=True)>
_
in front of the offending call, and after some trial and error, I can get
an
error to go away, but fxcop then complains about some new ones. After a
little more of this, I concluded that I was chasing my tail.
If you're not sure what permission is being evaluated in the original link
demand, you may want to use a decompilation tool like Reflector
(http://www.aisto.com/roeder/dotnet/) to examine it. This is a lot less
work than trial and error... ;)
Some examples are shown below. First comes what I am trying to do, 2nd
comes where fxcop complained, and 3rd comes my code that called the
offender.
Sorry, but I can't seem to make heads or tails of that list (which probably
has more to do with painkillers I'm taking for a broken leg than anything
inherent to your list <g>). If the matching link or full demand approach
doesn't work, perhaps you provide a simple and complete code sample that
provokes FxCop into the complaint that you're trying to address? If it's
compileable, I'd be quite willing to help run through the resolution...
.
- Follow-Ups:
- Re: fxcop and link demands
- From: AMercer
- Re: fxcop and link demands
- Prev by Date: Re: after changed the permisssion set to "nothing", I can't set the .net configuration anymore?
- Next by Date: Re: ReflectionPermission weird behavior?
- Previous by thread: Re: System.Security.SecurityException was unhandled
- Next by thread: Re: fxcop and link demands
- Index(es):
Relevant Pages
|