Catching security exceptions

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?
 
D

Dave

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.
 
J

Josip Medved

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top