Groups | Blog | Home
all groups > dotnet security > may 2006 >

dotnet security : Security permissions issue


Rich Moore
5/23/2006 8:06:02 AM
I've written an app in Visual Studio 2003 (C#) that I want to correctly
handle situations when the app is run from a network share. I've written
some code in the main form constructor to attempt to access the registry.
I've put this code inside a try/catch block and my app correctly displays a
nice error message to the user that the app will end. When this occurs, I
call Application.Exit() to exit out of my app but that causes another
security exception (I guess the Application.Exit requires permissions that
aren't available).

I've read some sites online that say the best solution is just to call the
..Close function for the form rather than Application.Exit. This isn't
working correctly, maybe because you can't call Close in the constructor? Do
I need to move all of this code to the .Load function or is there a better
way to handle this?

Any help would be appreciated.

Rich Moore
5/23/2006 12:46:02 PM
I hadn't thought of that. I changed my code and it works great. Thanks for
your help.

Rich

[quoted text, click to view]
Nicole Calinoiu
5/23/2006 2:06:03 PM
If this is a critical test that should prevent the application from running
upon failure, is there some reason you're not running it from the
application's Main method rather than from within form code?


[quoted text, click to view]

AddThis Social Bookmark Button