Solved

Windows Explorer being affected after VB.Net application closes.

Posted on 2014-04-10
6
332 Views
Last Modified: 2014-04-11
Thought I had discovered a solution to my problem but I guess not.  I thought that it was the built-in context menus in vb2008 that caused Windows Explorer to restart over and over after shutting the application down and using the right mouse button.  But after eliminating them, the problem still persists.  The only way to correct it is to shut down and restart Windows.

I realize this is probably a very ambigous question, but does anyone have an suggestions where to look for the problem within vb 2008.  I am not using any third party add ins.  Everything being used is from Microsoft.

Thanks in advance.
0
Comment
Question by:GCCal
  • 4
  • 2
6 Comments
 
LVL 40

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
If the problem starts to happen only after you close the application, then I would first look at the code that runs when you do stop the application.
0
 

Author Comment

by:GCCal
Comment Utility
Here is my shut down code.  See anything wrong with it, James.  Thanks....

        Try
            Microsoft.VisualBasic.DeleteSetting("NewCVR", "MySoftware", "Edit")
        Catch ex As Exception
            'do nothing
        End Try
        If MessageBox.Show("Confirm exit?", "Quit Color Video Report?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Cancel Then
            Exit Sub
        Else
            If MyPictureBoxes(0).Image Is Nothing Then

            Else
                If MessageBox.Show("Do you want to save the video report before exit?", "Save Video Report?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then
                    'Do nothing.....continue with exit
                Else
                    mnuSave.PerformClick()
                End If
            End If

            GC.Collect()
            Me.Dispose()
            Application.Exit()
            GC.Collect()
        End If
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
Comment Utility
GC.Collect? And twice? And after you requested that the application Exit?

Although you see it all over the place, there are very few instances where calling GC.Collect is a good thing. You are overriding the normal garbage collection mechanism (memory cleanup) when you call that method.

Assuming that you are in a Form, calling Dispose is usually quite sufficient.

And as stated in the documentation, GC.Collect "performs a blocking garbage collection", which means that it needs to stop currently running processes while it is cleaning up memory. Normally, it should not have an impact on Windows Explorer, since it is not a .NET application and the GC works only on .NET memory allocation, but who knows.

If removing GC.Collect does not solve your problem, put a breakpoint on Application.Exit, and step through the code with F11. Depending on how the application was started and what you did while it was running, some other code can run even after Exit.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:GCCal
Comment Utility
Okay, thanks James. I will give it a try and get back with you either today or tomorrow.
0
 

Author Comment

by:GCCal
Comment Utility
Thanks James.  I did as you suggested.  I delete GC and am only using Application.Exit.  Then I step through my code from that point and think I have found code that may have been causing me the problems.  Anyway, it has not occurred three times after shutting the software down.

Thanks for your help.
0
 

Author Closing Comment

by:GCCal
Comment Utility
Thanks for the expert advice....
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now