Re: fxcop and link demands



"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...



.



Relevant Pages

  • Re: Mad Men: What is so great about it?
    ... ...DVD's check out the first season, or see if it's on demand on your ... it's inarguably TV's Best Drama at present. ... Complaints about it becoming ...
    (rec.arts.tv)
  • Re: The end of Carbonite?
    ... that they can reliably - I think that they'd have to work based on complaints by the players. ... demand wasn't too intrusive. ... I'm sure that they have but I'm also sure that a lot of them play WoW and will download addons for their own use. ...
    (alt.games.warcraft)
  • Re: fxcop and link demands
    ... a link demand on behalf of a less privileged caller without forcing the ... I can do that by turning off this fxcop rule, ... than brief about 6 (some of the list is copy/pasted from fxcop's complaints). ... Public Sub T0 ...
    (microsoft.public.dotnet.security)