Security Exceptions - LocalIntranet

Hi,

We have a number of .Net winforms applications that run on our LAN. Some of our applications run from Network shares (LocalIntranet Security Zone) and require trust for the particular application.

This is fine, we have been including a package that applies the correct permissions as part of the install. However, some users are launching the application before applying the installation and get the ugly 'Application has generated an Exception that could not be handled' dialog box, because they do not have permission to run the executable from the share at that point.

OK, it's just users being over eager!! However, I'd like to trap the exception and show a much more graceful dialog informing them what they need to do.

At what point in code execution can the exception be trapped Here is an example of the opening statements of an application...

[STAThread]
static void Main() 
{
string mutexName = @"Local\" + EntryPoint.APPLICATION_ID;
using (SingleProgramInstance singleProgram = new SingleProgramInstance(mutexName))
{
  if (singleProgram.IsSingleInstance)
  {
  }
}
 

At what point is the exception being raised...immediately as it enters the thread \ code execution attempts to start

Cheers

Dylan



Answer this question

Security Exceptions - LocalIntranet

  • erikkl2000

    I was using declarative security at assembly level....e.g.

    [assembly:PermissionSet(SecurityAction.RequestMinimum, Unrestricted=true)]

    I've changed this to a programmatic demand within the Main() routine which I'm then trapping for exceptions. Seems to work fine...


  • E Davis

    You can simply demand FullTrust (not in Main, but in a method called from Main) and check for SecurityException. A good blog entry that describes this approach is http://blogs.msdn.com/shawnfa/archive/2004/12/02/274036.aspx.

    Brian Stern [MSFT]


  • Security Exceptions - LocalIntranet