I'm playing with CAS in Framework 2.0 (I know that it's obsolete).
I have following code, that I'm trying hard to crash. I've compiled project in 2.0 framework:
using System;
using System.Security;
using System.Security.Permissions;
namespace Authenticode
{
class Program
{
public static void DoSthmUnmanaged()
{
SecurityPermission perm = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
perm.Demand();
}
public static void Main(string[] args)
{
Program.DoSthmUnmanaged();
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
I copy exe
file to network drive, then open 'mscorcfg.msc' and evaluate assembly from network drive - Code group is Machine\All_Code\LocalIntranet_Zone
which is expected. When I execute it from network all works fine and I don't get it!
It's supposed to throw exception since code from LocalIntranet doesn't has permission to run unmanaged code. Why does it work?