Hi.
I'm new to this VB.Net mullarkey, and I must say it is proving to be a very
trying experience. Here is the latest in a long line of problems:
The Scenario
=========
I am building an MDI application. The first thing it does is to pop up a
little logon form which gathers and authenticates an SQL Server
username/password. It then whacks these into a couple of global variables
so they are available for any subsequent database access. Here are the
declarations of those variables (they are simply in a regular module):
Friend gstrUserName As String
Friend gstrPassword As String
Now, I have another form which is launched from a menu on the mdi parent.
Here is the code which does that:
Private Sub mnuCountries_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles mnuCountries.Click
Dim frmCountry As New frmCountry
frmCountry.MdiParent = Me
frmCountry.Show()
End Sub
BUT, one of the first things frmCountry does is to grab itself a middle-tier
object (a class) so as to populate the lists in some combo boxes, and in
order to do this it needs to pass in the SQL Server credentials mentioned
above i.e. it needs to refer to the two global variables. Hence, I have a
Form Load event procedure as follows (where cfrMain is a user control I have
created which has the combo boxes on it):
Private Sub frmCountry_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim objCountries As New midCountry
With objCountries
.UserName = gstrUserName
.Password = gstrPassword
End With
cfrMain.DataSource = objCountries
End Sub
Please feel free to criticise/comment on the general approach I have adopted
here, or any specifics in these code snippets (I am, after all, trying to
learn). However, the particular problem I have is that the statement
frmCountry.Show() throws a System.OutOfMemoryException error. HOWEVER, and
here's the weird bit, if I comment out the following two statements in
frmCountry_Load, then frmCountry shows OK:
.UserName = gstrUserName
.Password = gstrPassword
frmCountry also shows OK if I replace the references to the global variables
with literals e.g.
.UserName = "myuser"
.Password = "mypassword"
It also shows OK if it's not a child form.
So what's going on here? Why does something as apparently trivial as
referencing a couple of global variables result in an out-of-memory error?
And what can I do about it? And should I give up on the mdi application (a
trawl through Google groups shows a LOT of out-of-memory problems when
showing a child form, but no answers that I can find)?
Thanks for listening!
Baz 4 4145
Hi Baz
The first thing I noticed was that you define a variable with the same name
as a class. Whilst not forbidden, I would personally avoid this as it can
cause no end of problems when referencing the instance.
I would be inclined to change your click handler to something like
<code>
Private Sub mnuCountries_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles mnuCountries.Click
Dim frm As New frmCountry
frm.MdiParent = Me
frm.Show()
End Sub
</code>
then there is no confusion regarding which object is being referenced. This
may even resolve your problem.
HTH
Charles
"Baz" <bc**@clara.co.uk> wrote in message
news:10****************@lotis.uk.clara.net... Hi.
I'm new to this VB.Net mullarkey, and I must say it is proving to be a
very trying experience. Here is the latest in a long line of problems:
The Scenario =========
I am building an MDI application. The first thing it does is to pop up a little logon form which gathers and authenticates an SQL Server username/password. It then whacks these into a couple of global variables so they are available for any subsequent database access. Here are the declarations of those variables (they are simply in a regular module):
Friend gstrUserName As String Friend gstrPassword As String
Now, I have another form which is launched from a menu on the mdi parent. Here is the code which does that:
Private Sub mnuCountries_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuCountries.Click
Dim frmCountry As New frmCountry
frmCountry.MdiParent = Me frmCountry.Show()
End Sub
BUT, one of the first things frmCountry does is to grab itself a
middle-tier object (a class) so as to populate the lists in some combo boxes, and in order to do this it needs to pass in the SQL Server credentials mentioned above i.e. it needs to refer to the two global variables. Hence, I have a Form Load event procedure as follows (where cfrMain is a user control I
have created which has the combo boxes on it):
Private Sub frmCountry_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objCountries As New midCountry
With objCountries .UserName = gstrUserName .Password = gstrPassword End With cfrMain.DataSource = objCountries
End Sub
Please feel free to criticise/comment on the general approach I have
adopted here, or any specifics in these code snippets (I am, after all, trying to learn). However, the particular problem I have is that the statement frmCountry.Show() throws a System.OutOfMemoryException error. HOWEVER,
and here's the weird bit, if I comment out the following two statements in frmCountry_Load, then frmCountry shows OK:
.UserName = gstrUserName .Password = gstrPassword
frmCountry also shows OK if I replace the references to the global
variables with literals e.g.
.UserName = "myuser" .Password = "mypassword"
It also shows OK if it's not a child form.
So what's going on here? Why does something as apparently trivial as referencing a couple of global variables result in an out-of-memory error? And what can I do about it? And should I give up on the mdi application
(a trawl through Google groups shows a LOT of out-of-memory problems when showing a child form, but no answers that I can find)?
Thanks for listening!
Baz
Hi Baz
The first thing I noticed was that you define a variable with the same name
as a class. Whilst not forbidden, I would personally avoid this as it can
cause no end of problems when referencing the instance.
I would be inclined to change your click handler to something like
<code>
Private Sub mnuCountries_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles mnuCountries.Click
Dim frm As New frmCountry
frm.MdiParent = Me
frm.Show()
End Sub
</code>
then there is no confusion regarding which object is being referenced. This
may even resolve your problem.
HTH
Charles
"Baz" <bc**@clara.co.uk> wrote in message
news:10****************@lotis.uk.clara.net... Hi.
I'm new to this VB.Net mullarkey, and I must say it is proving to be a
very trying experience. Here is the latest in a long line of problems:
The Scenario =========
I am building an MDI application. The first thing it does is to pop up a little logon form which gathers and authenticates an SQL Server username/password. It then whacks these into a couple of global variables so they are available for any subsequent database access. Here are the declarations of those variables (they are simply in a regular module):
Friend gstrUserName As String Friend gstrPassword As String
Now, I have another form which is launched from a menu on the mdi parent. Here is the code which does that:
Private Sub mnuCountries_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuCountries.Click
Dim frmCountry As New frmCountry
frmCountry.MdiParent = Me frmCountry.Show()
End Sub
BUT, one of the first things frmCountry does is to grab itself a
middle-tier object (a class) so as to populate the lists in some combo boxes, and in order to do this it needs to pass in the SQL Server credentials mentioned above i.e. it needs to refer to the two global variables. Hence, I have a Form Load event procedure as follows (where cfrMain is a user control I
have created which has the combo boxes on it):
Private Sub frmCountry_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objCountries As New midCountry
With objCountries .UserName = gstrUserName .Password = gstrPassword End With cfrMain.DataSource = objCountries
End Sub
Please feel free to criticise/comment on the general approach I have
adopted here, or any specifics in these code snippets (I am, after all, trying to learn). However, the particular problem I have is that the statement frmCountry.Show() throws a System.OutOfMemoryException error. HOWEVER,
and here's the weird bit, if I comment out the following two statements in frmCountry_Load, then frmCountry shows OK:
.UserName = gstrUserName .Password = gstrPassword
frmCountry also shows OK if I replace the references to the global
variables with literals e.g.
.UserName = "myuser" .Password = "mypassword"
It also shows OK if it's not a child form.
So what's going on here? Why does something as apparently trivial as referencing a couple of global variables result in an out-of-memory error? And what can I do about it? And should I give up on the mdi application
(a trawl through Google groups shows a LOT of out-of-memory problems when showing a child form, but no answers that I can find)?
Thanks for listening!
Baz
Thx for the reply Charles. Good point about the naming.
I have changed the design so that UserName and Password, instead of being
properties of the middle tier object, are instead arguments of it's methods.
This involved moving the code that references the global variables, so that
it is now done by the user control, cfrMain, rather than in the Load event
of the form. It still gets done when the form loads, but it's a couple of
calls further down the stack, as it were. And...the problem went away.
Seems to be (yet another) bug in .Net. A few days ago I wasted a couple of
hours discovering the unreliability of setting the SelectedIndex for a bound
combo box to -1. Is programming in VB.Net always this frustrating?
Baz
"Charles Law" <bl***@nowhere.com> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl... Hi Baz
The first thing I noticed was that you define a variable with the same
name as a class. Whilst not forbidden, I would personally avoid this as it can cause no end of problems when referencing the instance.
I would be inclined to change your click handler to something like
<code> Private Sub mnuCountries_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuCountries.Click
Dim frm As New frmCountry
frm.MdiParent = Me frm.Show()
End Sub </code>
then there is no confusion regarding which object is being referenced.
This may even resolve your problem.
HTH
Charles
"Baz" <bc**@clara.co.uk> wrote in message news:10****************@lotis.uk.clara.net... Hi.
I'm new to this VB.Net mullarkey, and I must say it is proving to be a very trying experience. Here is the latest in a long line of problems:
The Scenario =========
I am building an MDI application. The first thing it does is to pop up
a little logon form which gathers and authenticates an SQL Server username/password. It then whacks these into a couple of global
variables so they are available for any subsequent database access. Here are the declarations of those variables (they are simply in a regular module):
Friend gstrUserName As String Friend gstrPassword As String
Now, I have another form which is launched from a menu on the mdi
parent. Here is the code which does that:
Private Sub mnuCountries_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuCountries.Click
Dim frmCountry As New frmCountry
frmCountry.MdiParent = Me frmCountry.Show()
End Sub
BUT, one of the first things frmCountry does is to grab itself a middle-tier object (a class) so as to populate the lists in some combo boxes, and in order to do this it needs to pass in the SQL Server credentials
mentioned above i.e. it needs to refer to the two global variables. Hence, I have
a Form Load event procedure as follows (where cfrMain is a user control I have created which has the combo boxes on it):
Private Sub frmCountry_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objCountries As New midCountry
With objCountries .UserName = gstrUserName .Password = gstrPassword End With cfrMain.DataSource = objCountries
End Sub
Please feel free to criticise/comment on the general approach I have adopted here, or any specifics in these code snippets (I am, after all, trying
to learn). However, the particular problem I have is that the statement frmCountry.Show() throws a System.OutOfMemoryException error. HOWEVER, and here's the weird bit, if I comment out the following two statements in frmCountry_Load, then frmCountry shows OK:
.UserName = gstrUserName .Password = gstrPassword
frmCountry also shows OK if I replace the references to the global variables with literals e.g.
.UserName = "myuser" .Password = "mypassword"
It also shows OK if it's not a child form.
So what's going on here? Why does something as apparently trivial as referencing a couple of global variables result in an out-of-memory
error? And what can I do about it? And should I give up on the mdi application (a trawl through Google groups shows a LOT of out-of-memory problems when showing a child form, but no answers that I can find)?
Thanks for listening!
Baz
Thx for the reply Charles. Good point about the naming.
I have changed the design so that UserName and Password, instead of being
properties of the middle tier object, are instead arguments of it's methods.
This involved moving the code that references the global variables, so that
it is now done by the user control, cfrMain, rather than in the Load event
of the form. It still gets done when the form loads, but it's a couple of
calls further down the stack, as it were. And...the problem went away.
Seems to be (yet another) bug in .Net. A few days ago I wasted a couple of
hours discovering the unreliability of setting the SelectedIndex for a bound
combo box to -1. Is programming in VB.Net always this frustrating?
Baz
"Charles Law" <bl***@nowhere.com> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl... Hi Baz
The first thing I noticed was that you define a variable with the same
name as a class. Whilst not forbidden, I would personally avoid this as it can cause no end of problems when referencing the instance.
I would be inclined to change your click handler to something like
<code> Private Sub mnuCountries_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuCountries.Click
Dim frm As New frmCountry
frm.MdiParent = Me frm.Show()
End Sub </code>
then there is no confusion regarding which object is being referenced.
This may even resolve your problem.
HTH
Charles
"Baz" <bc**@clara.co.uk> wrote in message news:10****************@lotis.uk.clara.net... Hi.
I'm new to this VB.Net mullarkey, and I must say it is proving to be a very trying experience. Here is the latest in a long line of problems:
The Scenario =========
I am building an MDI application. The first thing it does is to pop up
a little logon form which gathers and authenticates an SQL Server username/password. It then whacks these into a couple of global
variables so they are available for any subsequent database access. Here are the declarations of those variables (they are simply in a regular module):
Friend gstrUserName As String Friend gstrPassword As String
Now, I have another form which is launched from a menu on the mdi
parent. Here is the code which does that:
Private Sub mnuCountries_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuCountries.Click
Dim frmCountry As New frmCountry
frmCountry.MdiParent = Me frmCountry.Show()
End Sub
BUT, one of the first things frmCountry does is to grab itself a middle-tier object (a class) so as to populate the lists in some combo boxes, and in order to do this it needs to pass in the SQL Server credentials
mentioned above i.e. it needs to refer to the two global variables. Hence, I have
a Form Load event procedure as follows (where cfrMain is a user control I have created which has the combo boxes on it):
Private Sub frmCountry_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objCountries As New midCountry
With objCountries .UserName = gstrUserName .Password = gstrPassword End With cfrMain.DataSource = objCountries
End Sub
Please feel free to criticise/comment on the general approach I have adopted here, or any specifics in these code snippets (I am, after all, trying
to learn). However, the particular problem I have is that the statement frmCountry.Show() throws a System.OutOfMemoryException error. HOWEVER, and here's the weird bit, if I comment out the following two statements in frmCountry_Load, then frmCountry shows OK:
.UserName = gstrUserName .Password = gstrPassword
frmCountry also shows OK if I replace the references to the global variables with literals e.g.
.UserName = "myuser" .Password = "mypassword"
It also shows OK if it's not a child form.
So what's going on here? Why does something as apparently trivial as referencing a couple of global variables result in an out-of-memory
error? And what can I do about it? And should I give up on the mdi application (a trawl through Google groups shows a LOT of out-of-memory problems when showing a child form, but no answers that I can find)?
Thanks for listening!
Baz
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: solomon |
last post by:
Hi,
I have installed VS.Net(Ver:7.0.9466) & .Net_Frameword_1.0
(Ver: 1.0.3705). Until recently, I could develop and run
applications using the IDE.
A couple of days ago, I downloaded a sample...
|
by: king solomon |
last post by:
Hi,
I have installed VS.Net(Ver:7.0.9466) & .Net_Frameword_1.0
(Ver: 1.0.3705). Until recently, I could develop and run
applications using the VS.IDE.
A couple of days ago, I downloaded a...
|
by: Per Bergland |
last post by:
After many woes, I finally managed to get a stack dump of my System
Service (written in C#) that insists on crashing when launched at system
boot time (see below on how to get this dump - I...
|
by: Ripul Handa |
last post by:
Hi
We are running IIS 5.0 cluster with cisco local director.
We are running a website on 2 webservers and I have been
observing that from past few days we have are getting
this error message of...
|
by: SMG - Idealake |
last post by:
Hi all,
I am getting following error on my error, what could be the reason?
Exception of type System.OutOfMemoryException was thrown.
Description: An unhandled exception occurred during the...
|
by: Baz |
last post by:
Hi.
I'm new to this VB.Net mullarkey, and I must say it is proving to be a very
trying experience. Here is the latest in a long line of problems:
The Scenario
=========
I am building an...
|
by: Ashkan Daie |
last post by:
Hi All,
When trying to install a performance counter via InstallUtil I get the
following exception:
Creating performance counter category Enterprise Library Caching.
An exception occurred...
|
by: ari |
last post by:
I have a small form that comprises a toolbar, a treeview and a status
bar.
Everything was working fine until I decided to add a new button to the
toolbar - and I decided for appearances sake to...
|
by: =?Utf-8?B?UGlnZ3k=?= |
last post by:
Hi to all,
I am getting this System.OutOfMemoryException calling the
Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(<stream>,<Obj>) method.
The type of <streamis...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |