ATrain
December 22, 2010, 9:59pm
1
Do I need to revert access in my catch block before the error is thrown here? What happens if I don’t? I don’t completely understand the purpose of asserting permissions…
perm = new InteropPermission(interopKind::ClrInterop);
perm.assert();
try
{
// Do code
}
catch
{
throw error (“My error”);
}
CodeAccessPermission::revertAccess();
Hi,
you can write like i have shown below.
try
{
// Do code
//last line of try//–> CodeAccessPermission::revertAccess();
}
catch
{
//berfore throw error//–>CodeAccessPermission::revertAccess();
throw error (“My error”);
}
ATrain
December 23, 2010, 2:28pm
3
I know I can do that. But do I have to? Does permission revert automatically?
kranthi
December 25, 2010, 5:25am
4
You must call Assert method before invoking any secured API.
see the list of secured API’s http://msdn.microsoft.com/en-us/library/aa852189.aspx
see more about the asser() http://msdn.microsoft.com/en-us/library/aa655056.aspx