|
Has anyone else suffered a memory leak in their VB.NET programs?
I have a few classes that are created when a form is created. The whole thing is quite complex and wasn't written by me. I would expect any class I create to be destroyed when the form is closed, but they all seem to sit around in memory. The garbage collector just seems to shuffle about all the time and not free the memory.
Even when I do nothing in the application, the GC reports varying values for the GetTotalMemory() method. My problem is that I can't tell what is referencing the memory that can't be freed. A restart of the application is the only way to clear the memory at the moment.
Any advice? I'm getting desparate!
|
|
|
|
|
Google for '.NET Memory Profiler' or 'Allocation Profiler'. You'll find a bunch of them , some trial version, some shareware. I've used the Allocation Profiler from GotDotNet before with pretty good results, plus, you can get the source for it!
RageInTheMachine9532
|
|
|
|
|
I downloaded the trial of SciTech .NET Memory Profiler 2.0 (http://www.scitech.se/memprofiler/Default.htm). This tool helped me find the memory leak.
FWIW: When I create an event handler for a multi-line text box, the form sits in memory after being closed. I removed the handlers and the form is removed! I've never seen anything like it. I have NO CODE in the handler, just this:
Private Sub TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTextbox1.TextChanged
End Sub
And if I remove it, my 1K+ form will remove itself from memory. If the handler is in there, no number of GC.collect statements will free the damned thing.
Garbage I say GARBAGE !!!
Don't worry, nobody lives forever.
|
|
|
|
|
Hi, I want to implement a folder browser for VSS using VB6 (just like explorer in windows ). how do i go abt it? if any1 has sample code, plz share.
Antony
|
|
|
|
|
I don't know if that works in VB6, but it works in vb.net:
Add a reference to the SHELL32.DLL file (in WINDOWS\SYSTEM32). Then try the following code:
Dim folder As Shell32.Folder
Dim dlg As New Shell32.Shell()
folder = dlg.BrowseForFolder(Me.Handle.ToInt32, "Select a folder", 4)
Cosmin
|
|
|
|
|
I am trying to make a shareware application in vb .net that does some very simple CRM stuff. The problem I have is that, as i understand it, you need the .NET framework on every computer the application will run on.
Is there a way to compile the app. into a stand alone .exe that doesnt require the framework or is there something seriously flawed with my reasoning?? (Going back to VB6 sucks)
|
|
|
|
|
You MUST install the .NET Framework on every machine that will run the any .NET compiled app. You CAN NOT compile the Framework into your app. You, also, cannot include the .NET Framework in an installer package created by Visual Studio. This is because one of the first thing the resulting .MSI does is check to see if the Framework is installed. If not, the .MSI quits with the message 'This setup requires the .NET Framework. Please install the .NET Framework and run this setup again.'
You can make an installer, called a 'boot strap', for your app installation that checks for and installs the .NET Framework, then installs your app from it's .MSI package. See this[^] article and code sample on CP. Also, Microsoft has this[^] article on MSDN covering the same bootstrap principle.
RageInTheMachine9532
|
|
|
|
|
The reason there is a .NET framework
1. That all apps wil run on all pc's with the .net framework
2. You don't have to download huge files to get a .net application becouse all that is in the 20 MB .net framework.
3. Apps will work with all windows platforms with 1 code.
So you can't compile the framework in you app.
you can let the installer install .net framework read the help in VS.NET
|
|
|
|
|
Hai,
I have a problem with listview, when i Doubleclick the item in the Listview control ,item is checked automatically & call the itemChecked Event.I want to use these events as separate events,i.e when DoubleClick the item,i dont want to call itemcheck event. Please help me in this.
Lingaraja Patil.S
|
|
|
|
|
Unfortunately, you can't change that without changing how the user must click on the checkbox to change it's status. What's the purpose of double-clicking on the item?
What you might want to explore is a right-click context menu if you want the user to get details on an item.
RageInTheMachine9532
|
|
|
|
|
Update!
I found this ListView subclassed example on Experts Exchange:
using System;
using System.Windows.Forms;
using System.Diagnostics;
namespace WindowsApplication1
{
public class MyListView : ListView
{
private bool m_bIsFromDoubleClick = false;
protected override void OnItemCheck(System.Windows.Forms.ItemCheckEventArgs ice)
{
Debug.WriteLine ("OnItemCheck");
if (m_bIsFromDoubleClick)
{
ice.NewValue = ice.CurrentValue;
m_bIsFromDoubleClick = false;
}
else
base.OnItemCheck(ice);
}
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
Debug.WriteLine ("OnClick");
m_bIsFromDoubleClick = true;
base.OnMouseDown(e);
}
protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
{
Debug.WriteLine ("OnKeyDown");
m_bIsFromDoubleClick = false;
base.OnKeyDown(e);
}
}
}
With this example, double-clicking will change the check mark, but only if the mouse is ontop of the checkbox.
RageInTheMachine9532
|
|
|
|
|
thanks for your replay Dave Kreskowiak.
In VB6 application, the item checkevent & DoubleClick Event are two different events.I want samething in VB.net
First of all, I want to know weather this can be achived.
if not,any alternatives.
I thank you Once again for your help.
bye
Lingaraja Patil S
|
|
|
|
|
Uhhh...They ARE two different events in VB.NET.
What are your trying to do with these two events? What's different between the VB6 and the VB.NET implementation that you want to change?
Unfortunately, when an item has a checkbox, it works just like a CheckBox control. Clicking on it at all will generate an ItemCheck event. You can't stop the event from firing.
RageInTheMachine9532
|
|
|
|
|
Hi Gurus,
Am dynamically generating context menus from database.
I want to capture the click event on the menu item.
For example.
My context menu has
Copy
Rename
Send email
how will i know if "Rename" menu item or any other menu item has been clicked.
So that i can process different context menu click items
Please help me...
Thanks in advance
Sasidhar
|
|
|
|
|
Try setting the .OnAction property, for example
...
Dim cmdbarMenuItemCtl As CommandBarControl
... code to create command bar control etc.
cmdbarMenuItemCtl.Caption = "Send Mail"
'Set the .OnAction (click) property. When user clicks, the function
'MyFunctionName will be called with a string parameter containing an email address
cmdbarMenuItemCtl.OnAction = "=MyFunctionName('" & strEmailAddress & "')"
...
Jeremy
|
|
|
|
|
Sasidhar
You need to register an event handler for each menu item as you add it.
<br />
Dim mnuItem As MenuItem<br />
mnuItem = New Windows.Forms.MenuItem(MenuItemName, New System.EventHandler(AddressOf Me.MenuItem_Click))<br />
mnuMain.MenuItems.Add(mnuItem)
And then you obviously need the event handler as well. Use the sender.index value to determine which item in the menu has been clicked.
Private Sub MenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)<br />
Dim ItemIx As Integer = sender.index<br />
End Sub
Hope this helps
Bernhard
Don't worry, nobody lives forever.
|
|
|
|
|
Hi,
Where can I get source code of a Forum Board that uses Access as the back-end database? I have looked through several, but can't find any that uses Access as the database.
Any links or ideas?
Thanks...
|
|
|
|
|
|
Hey guys,
Well i hope somebody can help with this. Want to insert a picture in an Excel spreadsheet programatically using Visual Basic 6. It is possible n easy i guess but the real problem is that i want the picture to be inserted at a particular position say for example i wanna have the picture at P25 then what. Please consider that i m a beginner. thanx for all who help me out with this.
bye ;P
|
|
|
|
|
Hello Every body.
i cant add the data from the text boxes in the list veiw.
i have checked it but i cant.
can any one please tell me the coding.
thanks and with best regards.
Usman
|
|
|
|
|
We'll need a bit more detail about how you are using the listview to completely answer your qeustion. Some things like what mode the ListView is in? Are you using columns? What's the error your getting?
Also, how about posting what code you have so we can tell you what your doing wrong?
The basic add to a ListView from a TextBox:
ListView1.Items.Add( TextBox1.Text )
RageInTheMachine9532
|
|
|
|
|
List1.AddItem Rs2.Fields("name")
|
|
|
|
|
I made application using .NET 2002.and iam using crystal report.i deployed ina client system.but whe n i tried in another system,at the completion stage of setup ,it showing some error that "Crystl32.OCX" has failed to regsiter.and it is asking wether you want to countinue , retry or Ignore.clicking countinue setup can be completed.
But my application having user login interface,that is geting loaded,but further cant go.
PLease suggest me .i have tried to register Crystl32.OCX manually,that also not alowing me to do.and i tried to install crystal report 8.5 in order solve,that also not possible ,set up showing some error.
But this application is working fine in my development system using setup.
i have used all the merge module which require for .NET 2002 and crystal report.This is also happend in the 3rd system.
|
|
|
|
|
When you create your setup file you may need to add the ocx manually. VS.Net doesn't always pick up all the dependancies.
Definitely a PEBCAK! (Problem Exists Between Keyboard And Chair) My First ASP.Net site is now up http://www.redravenrpg.com
|
|
|
|
|
should i copy OCX into system32 folder,do i have to register?please explain me un detail.....thanxs
|
|
|
|