Why is this method requesting these permissions?

D

David Thielen

I have a class BeanResult which inherits from Object (ie no declared parent
class) and it does not have a ToString method so that inherits from Object.
One note, this is a J# class, not a C# one.

PermCalc gives the following listing which shows a permission request from
ToString which means that every class will then require UnmanagedCode as
every class eventually inherits from Object.

What is going on here?

<Type Name="BeanResult">
<Method Sig="instance void .ctor(string )" />
<Method Sig="instance void setColor(class Color )" />
<Method Sig="instance object MemberwiseClone()" />
<Method Sig="instance string ToString()">
<Demand>
<PermissionSet version="1"
class="System.Security.PermissionSet">
<IPermission version="1"
class="System.Security.Permissions.SecurityPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Flags="UnmanagedCode" />
</PermissionSet>
</Demand>
<Sandbox>
<PermissionSet version="1"
class="System.Security.PermissionSet">
<IPermission version="1"
class="System.Security.Permissions.SecurityPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Flags="UnmanagedCode" />
</PermissionSet>
</Sandbox>
</Method>
</Type>


--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

Dominick Baier

now you know how good permcalc really works....

by reading all your posts recently on CAS - i wonder what you are really
trying to do...

dominick
 
D

David Thielen

Are you being sarcastic or serious about permcalc????

The problem we face is that we have a potential customer who needs to use
our library in a partially trusted environment. AFAIK our code does not need
to touch anything outside it's own code except for the DNS and UDP capability
and we are reducing that to what we truly need.

But our code can, depending on how it is called, need to access lots of
things from the file system to the registry to ...

So I'm trying to figure out what we need to do so this guy can use our
library.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

Dominick Baier

well - i am not sarcastic...

so why don't you grant the specific permissions until it works? I think i
made a comment on another post saying that SocketPermission is not included
in e.g. medium trust - DNS IIRC is included.

I personally wouldn't fiddle around with RequestMinumum or Optional - just
document which permissions are needed - which you can figure out by trial
and error (at least thats how I usually approach that problem).

In my book I have a separate chapter on partial trust - maybe thats helpful
for you.

http://www.microsoft.com/mspress/books/9989.asp

dominick
 
D

Dominick Baier

i think you got this wrong...

the granted permissions are determined by a policy file found in the framework
config directory - e.g. medium trust maps to web_medium.config. This file
(or a copy of it) needs to get modified if the app needs more permissions
- e.g. the SocketPermission is not granted by default.

if you want to modify the behavior of your component depending on granted
permissions you can do a Demand() for the permission and see if an exception
gets thrown...

dominick
 
D

Dominick Baier

Hi,

the .config files defines all permissions granted to the appdomain running
your assemblies. The CLR loader can refuse to load the assembly if you have
RequestMinimum and Optional attributes in your assembly that do not match
the policy. That's i think the policy exception you are seeing....

IMHO - permcalc is not really useful as it shows a lot of permissions that
are not really needed. Run permcalc on a empty WinForms app - you will see
stuff like UnmanagedCode etc - which is just not true...

dominick
 
D

David Thielen

Ok, I'm really not understanding something here. permcalc operates on the dll
file so asp.net is not involved - correct? And my initial question was the
permission required for Object.ToString.

If it's the permissions in web_medium.config then any DLL by definition
would load in an ASP.NET app. It might not run if certain methods are called,
but it would load wouldn't it if that were the case?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top