views:

151

answers:

1

Tried out many things to run my application from a network location but nothing worked except increasing the Zone security for Internet Zone in the local machine to Full Trust using Microsoft .net framework 2.0 configuration.

Hence now I am trying to at least handle the error that occurs when I try to run the application from a network location and make it fail gracefully. But I am not able to do this also as the catch block, at the beginning of my code, where I am demanding fulltrust is not being executed at all. Can somebody suggest a way to do this?

My application uses Microsoft Report Viewer.

+1  A: 

In your Program.cs file is a line that starts the application, similar to the following:

Application.Run(new Form1());

You can, instead, replace it with the following:

try
{
    Application.Run(new Form1());
}
catch (SecurityException)
{
    // inform the user that they are not set up to run this application
}

This should catch any Full Trust issues that arise.

Michael Todd
Thanks for your reply Michael. I had tried this out but still control is not entering this try block and the application is failing.
aby sam ross
That's very strange; I use that mechanism for one of my applications. Do you have any lines prior to the Application.Run in your code?
Michael Todd
Yes Micheal, a few variable declarations are there.
aby sam ross
Well, that wouldn't make any difference with this issue. What exactly is the error message that's produced when you try to start your application?
Michael Todd
It says that my app has encountered a problem and needs to close. The error report contents show that the error code is 0xe0434f3d.
aby sam ross