I have three forms (form1-3). my startup form is form3. This form calls form1.show. then form1 does form1.visible=false and also calls form2.showat the end form1 shows again.
I have a general query that I need clarifying by some intelligent boffins such as yourselves. I have the following code in a function:[code]Obviously the Dispose method will never be called on the site object or the helper object. This may be a stupid question but can I get an explanation as to how these objects actually get disposed of in memory? Is it just by the fact that the enclosing method they were created in has been disposed of?![code]
I have a gridview where ALL cells have a value that is an image from the filesystem, but I need to access these files for a certain function and so I've been trying to create a method that disposes of all these images thereby freeing them up on the filesystem (was received permission denied errors). The following loop worked for the first row of images but I can't work out how to do it for all rows:
or Each c As DataGridViewImageColumn In dGV.Columns c.Image.Dispose() Next
Previous in my app, I've created dynamic controls and and named them blah0, blah1, blah2 etc. There will be a different amount created each time the user runs the app.I'm now trying to delete all of the controls but doing something very wrong. I've got the following
dim checkboxes = Controls.OfType(Of CheckBox).AsQueryable() dim sPrefix as string = "blah" for each checknum as checkbox in checkboxes
[code]....
When I execute the above, it only gets rid of every second control and I have no idea why. If I swap the dispose with a msgbox, the msgbox appears every time as I'd expect. It would seem that disposing of a checkbox seems to somehow requery the number available?
why upon exiting a form which has the following code i get an "Incorect syntax near the keyword 'FROM' " ? The form is supposed to be disposed , so why does any code gets 'executed' ?
Private Sub Fill_Data() Init_Comboboxes() For Each Lesson_Name As String In SQLArrayFunction("SELECT LName FROM LessonNames", "LName") ComboBox1.Items.Add(Lesson_Name)
i have frmMain as startup Form and frmsplash as splash screen now wat is happeneing is just my splash screen will not go off it remains there untill i click away from splash form somwhere on frmMain: One thing i have noticed and would like to share is: When i run my app. thru VS it works fine however when i run my myApp.exe splashScreen will not go off?
I have a class where there is some private strings to hold some data like name, address, etc. And also a private object of Process class. It also has an "AddHandler" method.
I misidentified the problem. It is actually like this:[code...]
Code analysis complains about this because ms can be disposed twice. That will only be true if zStrm, which takes the memory stream as an argument to its constructor, disposes of the memory stream when it cleans up. That seems like a totally nutty thing for the disposer to be doing. Does it really do that? Would a class that takes another class as an argument, be so uncivil as to dispose of that argument?
I suppose it would, since the alternative would be that the memory stream might not be disposed at all if it was created in the constructor like this:[code...]
I guess the only real question is whether or not I have to worry about this?
I've been working on a few large custom controls, and I noticed that when I use them, my memory starts ballooning. If I add a control at runtime, it increases the memory, but when I remove the control, it decreases less than it increased. However, it would stop balooning at some higher value. So if go back in forth between pages (which adds and removes the control), the memory would look something like this:
1,000K|5,000K|4,000K|9,000K|8,000K... 20,000K|25,000K|21,000K|25,000K|21,000K|25,000K... etc I know it takes a while for the GC to run, but the memory would stay consistantly high for long periods of time.
I tried writing a Closing routine, where when I called it, the control looped trhough its children and disposed all the internal controls, which seemed to help a little, but the memory after running the control and disposing was still much higher than before running the control. I also use custom event addhandlers. Should I remove all these as well. It would be nice if I received a little guidance on this.
I have declared Fonts at class level to use it through my methods in that form. Form 'frmA' is shown with ShowDialog and when it closes or stops using fonts I'd like to properly dispose fonts.When I run code analysis FxCop it complaints with:CA2213 : Microsoft.Usage : 'frmA' contains field 'frmA.Font1' that is of IDisposable type: 'Font'. Change the Dispose method on 'frmA' to call Dispose or Close on this field...How to properly dispose globally declared fonts so that is "by the rules" and FxCop does not complain any more?How to 'Change the Dispose method on 'frmA' to call Dispose'?
I am dynamically creating 12 picture boxes then click next and dynamically create the next 12 (in place of the first 12)
From what I can tell it is creating the next 12 I just can't see them. Do I first have to dispose of the original 12 first? if so how do I go about disposing of them?
Private Sub Pictures(ByVal DataXml As IEnumerable(Of XElement)) Dim song = DataXml MsgBox("song index " & SongIndex)
There to all gurus,I'm trying to build an Excel generation aplication using VS 2008 and Microsoft Excel 2003, but some how the Excel process that i create it's stuck in the computers memory, and it's only removed when I END the VB Application.
I have a button which opens FormTest. When FormTest opens, it creates an instance of ClassTest and that class instance takes the form instance that called it (FormTest) so that it can perform operations on FormTest from the ClassTest class instance. So i have a form which owns an instance of a class which has a reference to the form.
I'm building an application in VS2008 (VB) and SQL 2005. I'm using databindings to bind controls to LINQtoSQL objects. If I bind a 'third level' property that can be null I get "Value cannot be null. Parameter name: component" error while disposing the control.
Steps to reproduce (8):
1- create TEST database in SQL
2- create tables like this:
USE [TEST] GO /****** Object: Table [dbo].[Table03] Script Date: 06/04/2010 12:26:44 ******/ SET ANSI_NULLS ON
I am using Direct2D and the speed is so much better than gdi.however when i call the Dispose method of a D2DBitmap object no memory is freed up even after a garbage collection
so i guess my question is how can i properly dispose of a D2DBitmap object?
I'm making an MDI child window switcher (to set focus on selected child) sort of in a windows-style taskbar at the bottom of the program. I've got things set up so that when a child window is opened, a toolstripbutton is created and added onto the toolstrip and contains the window number and window type (what the window does). All that runs very well, but when I want to close a child form, I need to dispose the button that corresponded to it. I tried something like this:
For Each C As Control In frmClient.Controls If TypeOf C Is ToolStrip Then For Each tButton As ToolStripButton In C.Controls
[Code]....
But nothing happens at all. Is there a practical method to do this or am I missing something?
Brief : I have code which works if I don't dispose of the BindingSource after it has been assigned to DataGridView.DataSource but breaks if I do dispose it - why? Do I need to worry about disposing this?
[Code]...
So, what is going on here? When I set DataGridView1.DataSource = Bds does it just do this as a reference? How does Bds get disposed once the procedure exits? Does garbage collection pick it up if I assign something else to DataGridView1.DataSource? Do I need to worry about this?
I remove the datagridviewcomboboxcolumn from the datagridview and dispose it. When I go to dispose of the datatable that is the datasource to the comboboxcolumn an ArgumentOutOfRangeException is thrown from the datagridview. Apparently the datagridview is still handling events for datagridviewcomboboxcells for comoboboxcolumns that have been removed from the datagridview.
I've tried so many ways to get rid of picture boxes for my space invaders game, yet it's not working. The bullet hits the alien, the alien goes invisible (which it should) but it doesn't go to a new location or get disposed. And the bullet then intersects with it again but because it's invisible the user just see the bullet reset out of no where and the score gets added which it shouldn't.
Code: If Bullet1.Bounds.IntersectsWith(AlienArray(0).Bounds) Or Bullet2.Bounds.IntersectsWith(AlienArray(0).Bounds) Or Bullet3.Bounds.IntersectsWith(AlienArray(0).Bounds) Or Bullet4.Bounds.IntersectsWith(AlienArray(0).Bounds) And AlienHitArray(0) = False Then
[code]....
So, basically my question is how do I remove aliens (pictureboxes) off the board or disabled the picture box in space invaders when they are hit. (my bullet collision works fine).
Our application uses a custom DataAccessLayer class almost exclusively, and within that we do use Data Access Application Block (currently version 2). We are getting the infamous "GetOrdinal" error sporadically. We are not using out-of-method connections. We are using DAAB version 2. Below is a typical example of our DAL methods:
Public Function MyDALMethod(ByVal Param1 As Integer, ByVal Param2 As Integer) As System.Data.IDataReader Dim db As Database = DatabaseFactory.CreateDatabase()
[Code].....
My main question is should these DAL references be disposed somehow? It's a custom class written in VB.NET, so it doesn't implement IDisposable so I'm not sure if there's anything to be done or not, but we do have errors and issues (like the GetOrdinal problem) which seem to be load-related, and I'm wondering if this is part of the problem.
I'm trying to work out whether every Class in an Inheritance chain needs an explicit Dispose(disposing As Boolean) method or, if a given Class has neither managed nor unmanaged resources to dispose of, it can be skipped for that Class - even if a latterClass does require a Dispose method to dispose of mananaged or unmnaged resources?
Here's two examples: Public Class BaseClass Inherits Component 'Component has already implemented IDisposable
I can't believe I'm still confused about this but, any way, lets finally nail it:I have a class that overrides OnPaint to do some drawing. To speed things up, I create the pens, brushes etc before hand, in the constructor, so that OnPaint does not need to keep creating and disposing them.
Now, I make sure that I always dispose of such objects, but I have the feeling I don't need to because, despite the fact they implement IDisposable, they're managed objects. I've been vigilant in always using 'using' so that I don't need to go through all my code checking. I just wanted to be clear that I wasn't being a pointless user.As an aside, I did have a strange situation, recently, where I had to replace a using block and manually call dispose! I'll dig that out and create a new question.
Am trying to achieve a couple of things: merge a bunch of individual text files into a combined file, move the files that were combined into a new folder. I have assigned each of these tasks to a method. Something in the first method is hanging on to the file, even though I am closing and disposing the stream reader - but I can't figure out what. I know that a process from the first method is hanging on to the file because when I comment out the first method, the second method moves the files without a problem.
EDIT The first method is returning a value for new big file. This is passed as a parameter to the second method. When the second method tries to reference this file, that is when the program throws the error (5th line from bottom) Most posts on SO advise closing/disposing IO objects, but I am already doing that. They also advise using a third party tool to investigate what process is hanging on to a file, but I already know that it is the first merge method (because when it is commented out the program runs).
I am trying a example codes of animated graphics. I rewrote all the code and I found an error which doesn't happen on the example code(I run the example project)
error: 'Protected Overrides Sub Dispose(disposing As Boolean)' has multiple definitions with identical signatures.
when I double clicked the error, I got this in Form1.Designer.vb:
'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
I have a user control that inherits the FW ListView and I need to dispose of two objects when the form's disposing of it's objects. Here's what I've concluded already, am I on the right track?