I have been learning really hard to understand this .NET security thing, but
I still get overwhelmed with the abstractness.
The hardest part is to understand *when* you get an SecurityException and
*how* I would translate this into a simple-user-friendly messagebox.
And *when* you get a PolicyException and I also want to translate this into
a simple-user-friendly messagebox.
The idea is then to start up some HtmlHelp/WinHelp/web-page/readme.txt/...
in order to explain the user/his administrator how to configure this
program.
But as long as I don't understand this completely, then I cannot expect
other users of my program to understand this.
------------------
try {
Form1 form1 = new Form1();
Application.Run(form1);
} catch (System.Security.SecurityException e) {
string sError="This user account have not enough security rights to run
this program!\r\r"+e.ToString();
MessageBox.Show(sError+"\r\rThis program will now terminate!","ctRepair:
Security error",MessageBoxButtons.OK,MessageBoxIcon.Error);
} catch (System.Security.Policy.PolicyException e) {
string sError="The administrator of this machine did not give enough
trust this program to run!\r\r"+e.ToString();
MessageBox.Show(sError+"\r\rThis program will now terminate!","ctRepair:
Security policy error",MessageBoxButtons.OK,MessageBoxIcon.Error);
} catch (System.SystemException e) {
string sError="A system exception has occurred!\r\r"+e.ToString();
MessageBox.Show(sError+"\r\rThis program will now terminate!","ctRepair:
Security error",MessageBoxButtons.OK,MessageBoxIcon.Error);
} catch (System. Exception e) {
string sError="This program caused an unknown exception!:\r\r
"+e.ToString();
MessageBox.Show(sError+"\r\rThis program will now terminate!","ctRepair:
Unknown exception",MessageBoxButtons.OK,MessageBoxIcon.Err or);
} catch {
string sError="This program caused an unknown exception!:\r\r ";
MessageBox.Show(sError+"\r\rThis program will now terminate!","ctRepair:
Unknown exception",MessageBoxButtons.OK,MessageBoxIcon.Err or);
}