Home » VB.Net

VB.net Application not exiting completely

Hi, the application I am developing does not exit completely. i.e. the process can be seen in the Task manager. This happens only when I click on the [X] button on the title bar of the window of my MDI form. If I use the File >> Exit in the menu of my application, it exits without leaving any traces. I have used the "End" method there. But the process stays when I click the [X] on the control box on the title bar.

Thanks in advance,



5 Answers Found


Answer 1

Never use the End method. 

It kills an application, giving it no chance to clean up.

Simply use for the close the close and nothing more.

(The x button does that automatically)


Answer 2


what i think is that if u just click [x] button, it only causes the form onload, and it won't make the application stop.

what to do is u can try use Application.exit() method

here is a link regarding the application exit issues, may be u wanna read it


hope it is useful for u.


Answer 3


To use the application exit is only a good idea if you have started your program with Application.Run, both application Run and Application.Exit are done in most windows programs by the application framework, so it is seldom a good idea to use that.

Despite that some do.



Answer 4


There is a Shutdown mode in the properties of application in VS

Right click your project name->Properties->Application tab->Shutdown mode

two options for u to choose:

1. when startup form closes

2. when last form closes

Choose one base on the specific requirement.


Answer 5


Thanks for your reminding. It does make sense.

Best Regards,




I have just done my program, just skeleton not completely, the final problem has not been solved up to this time.



When I run my application, the Icon of its will be showed at TaskTray. I would like the icon is there when I exit fom of application and then If I double click on the Icon, the application will be showed.

In frac, now, when I exit app, the Icon also exit immediately.

Please, share your ideal.

Kind Regards,

[Using C#to implement]...




I have a software called Portal sold by Synapse Inc. It is basically software which interacts with microcontrollers.I need only some of the features of that software for my use. So i am thinking of developing a GUI which can emulate those feature and interact with the microcontroller. Am i going in the right direction in starting to develop the GUI?


i used the code below to try sending an e mail but did'nt work, I've gotten the mail server and port from my host company.


  Dim message As New MailMessage("sender@address", "from@address", "Subject", "Message Text")
        Dim emailClient As New SmtpClient("Email Server Name")

I am having some issues while executing "Call" statement via ODP.NET driver for a VB.NET application. Earlier when i was using "Microsoft ODBC for Oracle" driver, i was able to execute the "Call" statement succesfully.
I am having a stored procedure, which is getting executed via "Call" statement in a VB.NET application. For e.g.
Dim dt as DataTable
Dim strSql asString = "{call dummy_stored_proc({resultset 2,op1,op2,op3,op4})}
Dim cn asNew OracleConnection("Data Source=DS1;User Id=UID1;Password=PWD1;")
Dim cmd asNew OracleCommand(strSql)
cmd.Connection = cn
Dim da asNew OracleDataAdapter(cmd)

On executing the above dummy code, i get an Oracle exception "ORA=009000", Invalid SQL Statement. Could any one help me out in executing Stored procedures via "Call" statement via ODP.NET driver.


If I create a blank WPF application and run it, it shows a blank window named "WpfApplication1". But if I modify the default namespace, and change the namespace in the App.xaml(.cs) and MainWindow.xaml(.cs) files, the application just exits. What am I doing wrong and how I fix it?

Edit: Further testing revealed that this behavior starts when you change the assembly name in the project's properties.



I am new to programming and have just finished one of my first projects. I would like to possibly sell this application, but I need to figure out how I'm going to get the app. protected.

I plan on selling the program as a digital download and was wondering what the steps would be to issue serial licenses to the people who will purchase it.

Can anyone please direct the first few steps? It would be greatly appreciated.

Aaron C.

i am using front end application is vb.net, backend is sqlserver2005, in my vb.net application side getting a connection attempt failed..

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.


server stack trace



I am on the evaluation on VS 2010. I have a project that I imported to 2010 from VS 2008. It appeared it all went smoothly on import. However; when I tried to run the program I received a lot of errors related to the reportviewer. It wouldn't load the control at all and I couldn't even find the control in tools.

I do not use crystal reports, this is the reportviewer control from Microsoft. I was able to move from 2005 to 2008 without any issues but this one would be a problem for me, since I have a lot of reports and do not want to start over again with re writing those reports.

Please let me know what the issue is and how to fix this.


I need to create an array of a class type. Populate the values in the class and then pass
the array to a subroutine. I havent figured out how to do this properly as I get a null
reference exception. Can someone show me how to create/instantiate the array of objects?
Here is a simple example with only one property named "_momentum". My actuall class has about
10 properties/variables in actuality

Public Class Torsion

 Dim _momentum As integer

 Public Property Momentum
            Return _momentum
    End Get
    Set(ByVal As Integer)
      _momentum = value
End Propterty

' Later in the code I try to create and object of the class

Dim x(0) As Torsion

Hi everyone!
I am bignner in vb.net and i have developed a small application of vb forms in which i have use a service based sql server databas(.mdf)i want to make its msi installer last time i have made it and after installation application giving error for connecting to sql server plz help me.


I am developing in VB.net 2003.
I am defining 2 dropdown lists in a  web page

Lists are populated at run time

At run time, when I select an item from the first list:

- Clear the contents in second list

- populate the second list with 3 items.

when now, I select the last item from second list, the 2nd item is returned back instead of the last(3rd).

Note that when the IndexChanged event occurs for the list, it really returns the listindex 1 (2nd item) instead of 2 (3rd item). This is checked at autopostback time and at index changed time.
Same happens for 4 items but not for 2 in list
Note that if I select 2nd item and then the 3rd, it does not autopost back considering that is the same item(2nd)

I wonder if something must be done with Windows, or VB service packs, or any hidden properties ....or what else




I have VB.Net application that has worked fine for years on XP and Windows 7.  For some reason the last update I put out does not run even the simplest VB commands.  Simple   Environ() fails.  I have tried putting simple VB commands onto a MsgBox on the start of the app and everything raises an error.  I have no idea what is going on!   The exact same app runs fine on Windows 7 clients.   All the XP machines including a fresh XP virtual machine with the .Net 3.5 framework even gives the errors.  No VB commands are working.  I thought maybe something happened to my vbproj files, so I copied an older one from a couple weeks ago when things worked fine and it still does not work.   Does anyone have any ideas what in the world is preventing newly compiled VB.Net apps from compiling.   I did notice that Microsoft pushed several KB updates onto my machine even though I did not give it permission and it did it anyway.   I am wondering if some update corrupted my development environment.

How do I get this to work on the client computer in a web application :

MessageBox.Show(OnlineRepairListBox.SelectedItem.Text, "LEN Record Selected is :", _


MessageBoxButtons.OK, MessageBoxIcon.Exclamation, _


 MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification)

The message box appears on the server - I understand why, but I know there is a way to get this to work on the client.

Does anyone have any code as an example?



Hi guys


I need some help in deploying vb.net application using sqlserver database to work on local network I know I have to change connection string in  app.config but I don't know how to change connection string in app.config

Since I have this piece  of code almost in every form

    Private cs As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Mas-Database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")

thanks for help



I have a console application that is ready to be used as a windows service, I have been looking around for a couple of hours and tried many of the tutorials out there but none of them worked with me.  


The closest one was: http://beta.codeproject.com/KB/system/HybridService.aspx  but it didn't go into the process of doing it.  I converted that code to VB.NET but then I don't know where to go from there.  I have the Module1.vb which runs my console application all ready to be used.



If you could please show me a way to use my console application as a service, I would appreciate that.  I tried using the InstallUtil feature but my app never showed under "services".




   i've developed vb.net window application in english language.. its working fine but it has to support japanees language also..    

Displaying text, input text every thing should be japanees...

so user can select english or japanees, based on that label, input control language has to change..

is it possible ?

please help me, how can i do this..



Experts are invited to share their opinion. This is a debate that can never be fulfilled without you. Please come forward and respond.

What if we have a client who wants to develop a web enterprise application (based on SAAS architecture) and prefers for C# and not VB.NET based. Argument can be:

1. C# is better suited for developing enterprise application versus VB.NET
2. C# is object oriented versus VB.NET is not
3. Programming in C# is faster than VB.NET
4. Libraries/function blocks in VS.NET is more for C# versus VB.NET

I would request you to help me answer this. I believe this is the type of questions many faces when deciding for which language to go for, both developers and organizations. Experts please do not just read this, pause and give 5 min of your time, provide with a input that can help not just me, but many people in future looking for the same answer. 


I am creating a small VB.Net (Framework 3.5, Visual Studio 2008) application, requirement is small.
I want to make an EXE and that should run without installation.
I am Ok if all the dependencies, like dlls, are present in ApplicationStartupPath().
The Application should be standalone without installation. Bcoz, I don't want to create a big scene to install a huge .Net Framework in client PC for just a small application, as I said the requirement is small.
If I have to register any dll in client PC before my application to run, I will create a Batch file 
to do that operation and make it registered (I guess it's one time operation). But No Installation process. I Just do a copy paste of my compiled EXE and its dependencies in my client folder, it should be able to work on double click.

Is it possible to do such standalone project in VB.Net (.Net Framework 3.5). Anything other than installation may help.

Thanks in advance for any help regarding this.




I'm trying to design an application that will have a front end done using vb.net and a back-end using sql server, the application will access the database base remotely.

I was wondering if someone can help me with pointers on how to design the application and the mechanism to access the remote data, work with the data and update the remote database.

The database will not be on the same geographical location with the front-end, the communication will be done over the internet or a WAN



I have an application which collects user data via a form and assigns them to Public string variables held in a seperate module eg:

UserName, UserAge, UserHeight etc.

When this form closes I need it to Open the following file C:\UserDetails.xls

This is obviously an Excel document. In that Spreadsheet there are 10 visible Sheets and one "veryhidden" Sheet which is called UserData.

On the UserData Sheet there are a number of unlocked named cells:

Name, Age, Height etc.

I need my application on closing to Open the UserDetails.xls file and write the variables collected from the form to thier corrosponding named cells:

Excel Range(Name) = VB UserName, Excel Range(Age) = VB UserAge, Excel Range(Height) = VB UserHeight etc.

A breeze in VBA, but I have no idea where to start in VB

Can anyone help please?


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure