473,396 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

close application after a security exception

Hi all,

I've a window form application with 3 forms. I want to catch the
security exception when users run this application from a network share,
thus I've made this code (I've notice that excpetion has been throw by
initializecomponent()):

Try
InitializeComponent()
Catch ex As Security.SecurityException
MessageBox.Show(....)
me.close()
End Try

I've made this in the main form, but all forms throw the exception
causing debugger window appear to users, thus, I've made the try-catch
block on all 2 other forms InitializeComponent.

The messagebox appears 3 times (one per form) but the application wan't
close: a debugger window appear...

How can I do to application close after a messagebox to inform users?

thanks in advance and sorry for my bad english
Nov 21 '05 #1
5 1675
Nicola,

Me close means that the current instanced class closes.

Therefore probably as I understand you well, is the me.close not done in
your main class.

It is important what kind of form it is where you talking about when you
want some help to do it.
Mdi child,
a form showed with showdialog
a form showed with show.

I hope this helps,

Cor
Nov 21 '05 #2
Cor Ligthert ha scritto:
It is important what kind of form it is where you talking about when you
want some help to do it.


Simply it's the main form of the application (start form); when i launch
the application, the main form "initializecomponent()" method throw
that exception.... i want to catch her, show a message and close the
application.

I hope it's more clear...

thanks

P.S. also all other 2 forms in the application throw that exception, on
application launch...
Nov 21 '05 #3
Nicola,

When you write two other forms, than there has to be a difference. There are
not 3 main forms.

When you set in your main form me.close and you don't cancel that in your
closing event, than the application stops.

This assuming that you have not created yourself a kind of module to start
that mainform (than there is in my opinion actually not a mainform)

Cor
Nov 21 '05 #4
Cor Ligthert ha scritto:
This assuming that you have not created yourself a kind of module to start
that mainform (than there is in my opinion actually not a mainform)


Thanks Cor for your patience,

the main form is set in visual studio, not from a custom module: is this
the problem?

For a better explanation of my application:

1 Main form (application start here)
1 Options form (open in showdialog from a menu)
1 About form (open in showdialog from a menu))

Main form is the first form that i created in visual studio, and so is
set as first form to show when application start; have I to create a
module to start this form? Then can I close it with me.close()?

When I run the application from a network share, "initializecomponent()"
of all 3 forms throw the security exception... I don't know why all 3!

thanks
Nov 21 '05 #5
Nicola,

I show you a simple approach that should be work. (From what you show it
should throw three times an error however stop directly in the first form,
when you not have used a module (with sub main) or something else to stop
your application. Therefore I still don't unerstand it.
1 Main form (application start here)


dim Optfrm as new OptionForm
Optfrm.showdialog
if Optfrm.CloseAp then
Optfrm.dispose
me.close
end if
dim AboutFrm as new Aboutform
if AboutFrm.CloseAp then
OptFrm.dispose
me.close
end if
.....

And in those 2 forms
A global Boolean
Friend CloseAp as Boolean
And before your close
CloseAp = True
before me.close

Why the security issue now throws 3 times this error I don't know. that is
really not visible for me. However, in your case I would ask for that not
working security in the dotnet newsgroup for that, I never answer those
questions.

I hope this helps,

Cor
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Timothy Shih | last post by:
Hi, I am having a freezing issue with my application. My application serves several remotable objects, all of which must be initialized before their use. Furthermore, some of them depend on each...
5
by: PCC | last post by:
I am using the Exception Managment Application Block on Windows Server 2003 Enterprise and .NET v1.1. If I use the block with an ASP.NET web wervice or in a web application I get the following...
1
by: Alpha | last post by:
I have a Window based application that shows up still running in the task manager when I close it. It reaches the "this.close" statement and then it stops at the "}" at the section of the...
5
by: Lars-Erik Aabech | last post by:
Hi! Guess it's my day again.. Tried to deploy a test release of a new asp.net web today, and got a terrible error. The web is running swell on three development computers, but when it's copied...
0
by: M | last post by:
I installed the Visual Basic .NET Resource Kit. When I click 'Visual Basic .NET Resource Kit' the page at 'http://localhost/VB.NETResourceKit/Welcome.aspx' show: Server Error in...
2
by: Alex | last post by:
My Problem is that although i have added a handler to Application.ThreadException and it works fine for my application exceptions, it does not fire if an exception is generated inside an event...
3
by: Joris De Groote | last post by:
Hi, I use Adobe Acrobat to read tekst from PDF files. After that the file has been read, I move the file in a folder (using the date I got from the text I got from Acrobat). Now here is my...
5
by: Frank Rizzo | last post by:
I have a c# 2.0 winform app that runs under a user account with very limited rights. The application crashes on some actions (the Send Error to Microsoft screen) with unauthorized exception. ...
3
by: ajl | last post by:
I am getting following error on accessing a asp.net application from virtual directory /website. Please suggest me the solution. Server Error in '/website' Application....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.