Hi;
I'm still not getting something. I now have:
[assembly: UIPermission(SecurityAction.RequestOptional, Window =
UIPermissionWindow.AllWindows)]
And am getting this on startup:
System.Security.SecurityException was unhandled
Message="Request for the permission of type
'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
Source="mscorlib"
GrantedSet="<PermissionSet
class=\"System.Security.PermissionSet\"\r\nversion=\"1\">\r\n<IPermiss
ion
class=\"System.Security.Permissions.SecurityPermission, mscorlib,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089\"\r\nversion=\"1\"\r\nFlags=\"Executio
n\"/>\r\n<IPermission
class=\"System.Security.Permissions.UIPermission, mscorlib,
Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089\"\r\nversion=\"1\"\r\nWindow=\"AllWind
ows\"/>\r\n</PermissionSet>\r\n"
PermissionState="<IPermission
class=\"System.Security.Permissions.UIPermission, mscorlib,
Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089\"\r\nversion=\"1\"\r\nUnrestricted=\"t
rue\"/>\r\n"
RefusedSet=""
Url="file:///C:/src/TestPerm/TestPerm/bin/Debug/TestPerm.EXE"
StackTrace:
at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence
assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object
state)
at System.Threading.ExecutionContext.runTryCode(Object
userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuarante
edCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at
System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
One of the choices in the debugger prompt was "Add Permission to the
project" - I clicked on that, exited VS2005, started it again, and
still get this.
What am I missing?
Cubicle Wars -
http://www.windwardreports.com/film.htm
Dominick Baier said:
RequestMinimum makes sure you have this permission. Not that all
others are disabled.
Try RequestOptional instead.
-----
Dominick Baier (
http://www.leastprivilege.com)
Developing More Secure Microsoft ASP.NET 2.0 Applications
(
http://www.microsoft.com/mspress/books/9989.asp)
Hi;
I assumed the following code would not load. And if it loaded, would
throw an exception on the OpenText. However it runs fine.
AssemblyInfo.cs:
// only permission - set to cause all other to be disallowed
[assembly: RegistryPermission(SecurityAction.RequestMinimum)]
Program.cs:
class Program
{
static void Main(string[] args)
{
MyObj obj = new MyObj();
string str = obj.ToString();
File.OpenText(str);
}
}
class MyObj
{
public override string ToString()
{
return "dave.txt";
}
}
Why does this work?
Cubicle Wars -
http://www.windwardreports.com/film.htm