4
Answers

Stop C#.net program early in execution cycle

jasminie

jasminie

13y
2.2k
1
I have a C#.net 2008 desktop application that I would like to stop before the first desktop screen shows up. I want to stop this application from executing immediately if the user has not been granted access to the application after looking up what access they have been granted by the active directory.

I want to stop the application before the following statement is executed: Application.Run(new Mainform());

i would like to stop the application from running in program.cs.

The only options that are close to what I want to do are:

Application.ExitThread(); or Application.Exit();

However these statements run after the Application.Run(new Mainform()); statement is executed.

Thus my questions are:

1. Is there way to not display the first desktop screen? If so, what would be code be?

2. If that is not possible, what are my other options? Do I just display the desktop tabs and let the user select the tabs they want to work with? if the user does not have access to that tab, do i display a message saying 'no access' and redisplay the screen like it was before the user clicked on the tab? if so, can you show me some example code?

3. If my options do not work, what do you suggest and can you point me to a reference of some code I can use?

Answers (4)