views:

225

answers:

2
+2  Q: 

Assembly Evidence

Hi

What is the purpose of the following piece of code?:

object[] hostEvidence = {new Zone(SecurityZone.Internet)}; 
Evidence internetEvidence = new Evidence(hostEvidence, null);
AppDomain myDomain = AppDomain.CreateDomain("MyDomain");
myDomain.ExecuteAssembly("SecondAssembly.exe", internetEvidence);

As far as I know the CLR automatically (It asks Windows for it) assigns the Zone depending on where the assembly is run from (local machine, internet ect...). I am guessing that it was meant to decrease the permissions for the assembly but when we have two evidences we also have two code groups which are summed within a given policy level.

Kind Regards PK

+1  A: 

According to the .NET Framework foundation book (I've not yet quite memorised it for the exam), Evidence is either user specified (.NET Configuration Tool) or Developer specified. So in this way you are explicitly defining the Zone that you need.

I'm not aware of the CLR automatically assigning zones though I might be wrong.

Ian
The CLR does not automatically assign zones as such more then assume them based on the location of the file and the default security policy. Ie. if running a file on my local machine it is assumed to be fully trusted etc.
Diago
It does not assign but it asks Windows for Zone information.
pkolodziej
Here is the article about how CLR gets the zone evidence for the assembly:http://blogs.msdn.com/shawnfa/archive/2006/05/12/596419.aspx
pkolodziej
A: 

Hi

I would expect this overload of the ExecuteAssembly method uses the supplied evidence instead of automatically assigning new evidence. Otherwise, what would be the point?

Tor Haugen