Asp.net - Dispose & Finalize For Collections Of Properties?

Apr 20, 2009

I'm looking at some vb.net code I just inherited, and cannot fathom why the original developer would do this.

Basically, each "Domain" class is a collection of properties. And each one implements IDisposable.Dispose, and overrides Finalize(). There is no base class, so each just extents Object.

Dispose sets each private var to Nothing, or calls _private.Dispose when the property is another domain object. There's a private var that tracks the disposed state, and the final thing in Dispose is GC.suppressFinalize(Me)

Finalize just calls Me.Dispose and MyBase.Finalize.

There are no un-managed resources, no db connections, nothing that would seem to need this.

View 4 Replies


ADVERTISEMENT

Implement Dispose Or Finalize?

Feb 15, 2010

Class ComponentsContainer ' a component contains other components'
Inherits System.ComponentModel.Component
Private foo as New Component
Private bar as New Component
Protected Override Sub Finalize()
foo.Dispose() ' HERE ? '
bar.Dispose()
MyBase.Finalize()
End Sub

Protected Overrides Sub Dispose(disposing As Boolean)

[Code]...

View 4 Replies

Finalize() Or Dispose() A Module In Program?

Apr 21, 2011

Is there a way to Finalize() or Dispose() a Module in VB.NET? Have a situation similar to the following and need to Dispose() itsUnManagedObject.[code]...

View 2 Replies

User Control Properties - Finalize My Design Time Properties Grid

Apr 27, 2011

I'm making a control and I am trying to finalize my design time properties grid. I have several List(of Class) items as public properties and when I click on the design time menu (while testing the control) there is the word "Collection" and a button with an ellipsis (...) that brings up a neat pop up with the buttons Add/remove and all of the public properties of the collection's class on the right hand side. Basically for a non-collection instance of a class (with public properties) I'd like a similar button to show up. I know I could put all of the properties in the main control class and group them, but I like the pop up box feature. Anyway to duplicate this? (think font grid item etc.)

View 3 Replies

C# - System.Data.SqlClient.SqlTransaction.Dispose - Protected Override Void Dispose(bool Disposing)

Jun 25, 2012

I looked at the Dispose() method in System.Data.SqlClient.SqlTransaction (using a decompiler):

[Code]....

Why does everyone say in forums that it is Rolling back in the dispose? Where does it rollback?

View 1 Replies

Asp.net - Value Of Type 'System.Collections.ArrayList' Cannot Be Converted To 'System.Collections.Generic.List(Of ITextSharp.text.IElement)'

Sep 21, 2011

I'm having a problem with this code in the highlighted line(*); getting the error in the heading.

Dim htmlarraylist As New List(Of iTextSharp.text.IElement)
htmlarraylist = *HTMLWorker.ParseToList(New StreamReader(tempFile), New StyleSheet())*

[Code].....

View 2 Replies

System.Collections.Specialized.StringCollection Vs System.Collections.Generic.List(Of?

Feb 5, 2011

[code]...

What's really the point in using the former?It's hard to use linq if I used the former. I have to convert that to an array first which is difficult because there is no (asarray) function.I think I would change all of my code that's using System.

Collections.Specialized.StringCollection to System.Collections.Generic.List(Of String)

View 2 Replies

C# - The Cost Of Finalize In .Net?

Jun 15, 2010

(1) I've read a lot of questions about IDisposable where the answers recommend not using Finalize unless you really need to because of the process time involved.What I haven't seen is how much this cost is and how often it's paid. Every millisecond? second? hour, day etc.

(2) Also, it seems to me that Finalize is handy when its not always known if an object can be disposed. For instance, the framework font class. A control can't dispose of it because it doesn't know if the font is shared. The font is usually created at design time so the user won't know to dispose it, therefore finalize kicks in to finally get rid of it when there are no references left. Is that a correct impression?

View 5 Replies

GC.SuppressFinalize Does Not Suppress Finalize

Jan 25, 2010

when i call GC.ReRegisterForFinalize(obj) and changed my mind, i could call GC.SuppressFinalize(obj) and remove it from the list of object that requests finalization. problem is that when i call GC.ReRegisterForFinalize(obj) twice, it registers the object twice in the finalization-listing. i need to remove the object from the finalization-listing but multiple calls of GC.SuppressFinalize(obj) could not remove obj from the list.also, why is it acceptable for this function to be called SuppresFinalize when after calling it Finalize still occurs?

View 2 Replies

Finalize Calling Class Method?

Mar 21, 2012

I have a logging class that stores entries in a datatable dt. I then use SQLBULKCOPY to write that dt out to a sql table. Basic stuff. Problem is, I'd like to only call SQLBULKCOPY when there's say 50 entries in the dt. The problem is, what if I'm done (either intentionally or not, like if the code block that's using the log class throws an exception) with the logging object and there are still 15 rows in the dt?

View 1 Replies

Implement Finalize To Remove An Object?

Dec 24, 2009

how do we implement Finalize to remove an object?i tried this:

Public Sub kill()
Me.Finalize()
End Sub

then this:

Dim g = New Test
g.kill()
MsgBox(g.ToString)

weird the object still exists, i don't get a NullReferencePointer exception

View 4 Replies

IDE :: Interaction Of Finalize And Default Implementation Of IDisposable() Interface?

Apr 20, 2009

I am comparing an alternative Dispose pattern to VS2005's default implementation. In doing the comparison I have found several uncertainties with the default pattern which have raised a handful of questions related to sub-class implementations and object Finalization.

[Code]...

View 1 Replies

Why Does Finalize Not Get Fired When Try To Destroy A Class Until The Application Is Exiting

May 4, 2010

why does finalize not get fired when i try to destroy a class until the application is exiting. i feel like because these objects were never actually finalized until the program is exiting that its somehow bogging down the operation of my app VS 2008?

View 1 Replies

Make Custom Properties In Properties Window To Refresh Upon Change Via Code?

Apr 26, 2012

[code]I want to make the Properties Window to update the properties for X and Y at each MouseMove, so they become immediately visible for the user.

View 2 Replies

VS 2010 Express - PictureBox Design Properties Box Shows Properties That Cannot Be Accessed?

Mar 5, 2012

In the form design I set up a TableLayoutPanel, 20x20 cells and in cell (1,1) a PictureBox (called Target) containing the image of a small target. The properties box for Target shows some very promising properties, Column and Row - and if you overwrite the values in the properties box, the PictureBox obligingly shifts to the corresponding cell position in th design. However in VB it is not possible to refer to Me.Target.Row or .Column - neither appears during coding in the menu of properties, and deliberately coding either of them produces an error like

Error 1 'row' is not a member of 'System.Windows.Forms.PictureBox'.

1. Why does the properties box show properties that cannot be altered programmatically?

2. How can my program move Target around in the TableLayoutPanel?

View 10 Replies

Expose A UserControl's Properties To Properties Window In Designer?

Aug 19, 2009

Is there a way to expose a UserControl's properties to the Properties Window in the Designer?

View 3 Replies

Set The Transparent Property Via Label Properties Properties Not Via Code?

Jan 16, 2009

I'm working on a Hazardous Materials label printing program. One of the options is to do an "NFPA" label. Since there are 4 values required with 4 or 6 options, the ratings are entered via radio buttons in a group box. That's working okay. I display values in the NFPA diamond as they're entered: left quadrant blue, top quadrant red, left yellow, bottom red. I'm having trouble with the label in which the rating will be displayed on top of a jpg diamond for the white. In this quadrant the text can be up to 4 characters. I can accept the text going into an adjacent block a little, but the corners of the label overlap into another quadrant/color. I reduced the font size which solved the overlap problem but the font is then too small and looks terrible. I tried to make the background of the label transparent to let the color come through correctly but that's not a valid value for label.background. I'm figuring that the transparent background is the best solution. What can I use that will accept a transparent background so the color shows through?

I'm trying to set the transparent property via label properties properties, not via code. Here's the code if it makes any difference:

Public Class NFPA
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Close()
End Sub

[code]....

View 2 Replies

Change All Properties Of A Form To Properties Of Other But Don't Change Important Properties?

Feb 26, 2011

How to change all properties of a form to properties of other but don't change important properties like Owner,Handle, OwnedForms, Parent,HasChildren,Controls and ... .I have a child form that i want it to provide controls of Form.The background form provides Aero frame and child form is a transparent form in it.I want it because I want to draw buttons with system style in Aero in Windows Forms.This is my own code but it does not work good (ForeForm is child form):

For Each Propertry In ForeForm.GetType.GetProperties()
Select Case Propertry.Name
Case "AeroBackgroundEnabled", "FormBorderStyle", "TransparencyKey", "Parent", "Owner", "ShowInTaskbar", "Handle", "HasChildren", "OwnedFo[code].....

Additionaly:I wrote a great Aero Form.I don't publish current version (1.2) that supports Aero Blur,RealTime Aero Color change,extend Basic theme?

View 13 Replies

How To Add Collections To Class

Feb 12, 2010

I would like to create a customer class and be able to add collections to it. I know I have to use List<T>. Look at the scenario below. I have a customer class, order class and address class. I would like to instantiate the customer class and add orders and addresses to it. E.g.

Dim oCustomer As New Customer("Acme Inc.")
oCustomer.Orders.Add(New Order(1))
oCustomer.Orders.Add(New Order(2))
oCustomer.Addresses.Add(New Address("Street 1"))
oCustomer.Addresses.Add(New Address("Street 2"))
[Code] .....

View 3 Replies

Using Collections In A WebService?

Mar 18, 2011

I created a website that contains a Webservice that transfers data to a windows application Using a collection, however, I get this Error that says that anything that inherits the ICOllection, it must implement Add(System.Object)

View 2 Replies

Collections And Interfaces And Casting?

Nov 14, 2010

Say I have a interface called IProperties and I have a collection called colMyProperties that is a collection of IProperties. Then I have an object called clsProperty that implements the IProperty interface. Now, in my code where I add objects to the colMyProperties collection I add a bunch of clsProperty objects. so far so good.

Now when I try to access an object in the collection I can only access properties and methods of the IProperties interface, not the clsProperty object. What am I doing wrong? Do I need to cast the object?

View 2 Replies

Collections Of .NET EntityObjects Contain Any Of The Same Objects?

May 19, 2009

Pages have Roles. Users have Roles. A user may only view a page if he and it share one or more roles.

This works:
Dim Allow As Boolean = False
CurrentPage.Roles.Load()
For Each r As Role In CurrentPage.Roles
r.Users.Load()

[Code]...

How can I make it compare only the Role Id values to determine equality?

View 1 Replies

Control Collections In A Tabcontrol?

Dec 21, 2011

I have a form with a tabControl on it. This tabControl has 10 tabs and each tab has multiple textboxes. I am trying to iterate through these textboxes, but cannot find which collection these textboxes belong to within the project.

View 2 Replies

Converting VB6 Collections To .Net Generics?

Apr 21, 2012

I have a VB6 project with about 100 custom collection classes which I want to convert to VB.Net. A typical example would be something like.

Class CAccounts
Private m_Accounts As New Collection
Public Sub Add(newItem As CAccount)
m_Accounts.Add newItem, newItem.IdKey

[code].....

All of the collection classes in the project use this standard approach. However, not all the properties/methods of the collection classes are actually used. Most of the collection are used in "for each" loops. Keyed access using the string key is quite common. Keyed access by index is much less common.

Ideally I'd like to take a standard approach to converting these classes. I don't really want to have to review each collection and it's usage to consider whether I need a List, Dictionary, etc. Some of these collection contain 100,000 objects, and some will only contain 10. However, on the other hand I don't want to cause performance problems by using a more complex structure where a simpler option would do.

Sticking with the old style Collection. So, it would be relatively easy to convert to VB.Net But, I'd rather move to the more modern structures.Have CAccounts Inherit KeyedCollection(Of String, CAccount). Fortunately most of the classes held in the collections do have the key as part of the class (eg CAccount.IdKey above). This seems to work well. However, relatively few classes will access the colelction by numeric index. So, perhaps this is overkill if I only want keyed access by the string key?Have CAccounts Inherit Dictionary(Of String, CAccount) for the classes where I don't need access by numeric index. The problem I have with this is that all the existing "for each" loops are like "for each account in accounts". I don't want to have to change all these occurences to something like "for each account in accounts.Values". Although perhaps I can get round this by changing the default property?Have CAccounts Inherit MyCollection(Of String, CAccount), where MyCollection is my own bespoke collection. This seems a bit too much hard work.

View 2 Replies

Create A Collection Of Collections?

Sep 16, 2009

Is there a way to create a collection of collections? e.g. I created a collection ListOf(Lines) After I add all my lines to it, I want to store this colleciton in another listOf(Collections). The reason I want to do this is because i want to create several separate collections of lines and I'll need to loop through them all to look for a certain line and I thought this would be a good approach if it's possible.

[Code]...

View 5 Replies

For Each Through Public Collections Within A Class

Sep 17, 2010

I have a class that is primary configuration for my application. It has 70 plus public collections that holds all my data. I am trying to do a For Each through each of these public collections, so that I can process the data through my code, but I am getting following error:

[Code]...

View 3 Replies

Generic Collections And Inheritance?

Aug 24, 2009

I have a parent class and many children class, right now it look like this:

Public Class Parent
Public Property ID as String
End Class

[Code].....

What I need is a strongly type list List(Of Child) that Inherits from ListOfParent (I need the FindByID method) but I can't find the right syntax.

View 10 Replies

Make Collections Last After Close?

Mar 10, 2012

Is there a code to make the contents of a collection stay the way that they (everything is still stored) are instead of being erased when I close my program?

View 6 Replies

One Routine For Loading Collections

Sep 2, 2009

I would like to have 1 routine to load data into different collections.I would like to use the below routine in a more dynamic fashion...be able to load a different collections with different data dependent on strSQL.Is there a way I can pass the collection I want to use.If so, in the below code how would I differentiate to load the correct data to the correct collection? [code]

View 22 Replies

Searching List Collections?

Mar 21, 2011

My problem is probably something simple..I am trying to load a list of a perticularcustomer.I will have to load the list of all the purchases they have make (amount of tickets purchased (rseat). It runs fine, but when I change the file name from fri to saturday and keep the call name the same it still searches to the name that is in the call name textbox. I dont want it to do that. I want it to say the there are no reservation for that name if I change the file.here is part of my code.

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
'resets file reader and put to the top of txtfilename

[code].....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved