Catching security exceptions

  • Thread starter Thread starter Josip Medved
  • Start date Start date
J

Josip Medved

When I run my code I get "Application has generated
exception that could not be handled." This message
appears only when I try to run application from network
share. Reason is lack of application's dll assembly
security permissions. How can I handle this case and
inform user of this in more human way than to popup
generic error.
In short: I need to intercept assembly loading failure that
occurs before first line in my program even executes.
How?
 
When you run from a network share by default the executable is getting
loaded using the permission set granted to the Intranet security zone. If
your assembly is decorated with attributes demanding a minimum permission
grant before loading then it wont even load, otherwise it will try to load
until it executes something that requires a resource for which it has not
been granted the required security permission.

The easiest option is to run your application from the local file system -
this by default runs with full trust. Another option is to sign your
assembly with a strong name, create a code group whose membership condition
is that strong name and to which you grant full trust, and then add the code
group to the machine policy level.

You can also post this question on the security newsgroup - they can provide
much more info on this.
 
The easiest option is to run your application from the local file system -
this by default runs with full trust. Another option is to sign your

I know why is that happening. I know how to bypass that. Only thing
I want is to be able to inform end user of error. It looks ugly when
someone gets such message. Since users usually install program
themself it is not possible for me to control that aspect.
 
Back
Top