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_Cl ick(ByVal sender As Object, ByVal e As
System.EventArg s) Handles mnuCountries.Cl ick
Dim frmCountry As New frmCountry
frmCountry.MdiP arent = 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.EventArg s) Handles MyBase.Load
Dim objCountries As New midCountry
With objCountries
.UserName = gstrUserName
.Password = gstrPassword
End With
cfrMain.DataSou rce = 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.OutOfMem oryException 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 4189
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_Cl ick(ByVal sender As Object, ByVal e As
System.EventArg s) Handles mnuCountries.Cl ick
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_Cl ick(ByVal sender As Object, ByVal e As System.EventArg s) Handles mnuCountries.Cl ick
Dim frmCountry As New frmCountry
frmCountry.MdiP arent = 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.EventArg s) Handles MyBase.Load
Dim objCountries As New midCountry
With objCountries .UserName = gstrUserName .Password = gstrPassword End With cfrMain.DataSou rce = 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.OutOfMem oryException 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_Cl ick(ByVal sender As Object, ByVal e As
System.EventArg s) Handles mnuCountries.Cl ick
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_Cl ick(ByVal sender As Object, ByVal e As System.EventArg s) Handles mnuCountries.Cl ick
Dim frmCountry As New frmCountry
frmCountry.MdiP arent = 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.EventArg s) Handles MyBase.Load
Dim objCountries As New midCountry
With objCountries .UserName = gstrUserName .Password = gstrPassword End With cfrMain.DataSou rce = 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.OutOfMem oryException 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******** ******@TK2MSFTN GP12.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_Cl ick(ByVal sender As Object, ByVal e As System.EventArg s) Handles mnuCountries.Cl ick
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_Cl ick(ByVal sender As Object, ByVal e As System.EventArg s) Handles mnuCountries.Cl ick
Dim frmCountry As New frmCountry
frmCountry.MdiP arent = 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.EventArg s) Handles MyBase.Load
Dim objCountries As New midCountry
With objCountries .UserName = gstrUserName .Password = gstrPassword End With cfrMain.DataSou rce = 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.OutOfMem oryException 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******** ******@TK2MSFTN GP12.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_Cl ick(ByVal sender As Object, ByVal e As System.EventArg s) Handles mnuCountries.Cl ick
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_Cl ick(ByVal sender As Object, ByVal e As System.EventArg s) Handles mnuCountries.Cl ick
Dim frmCountry As New frmCountry
frmCountry.MdiP arent = 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.EventArg s) Handles MyBase.Load
Dim objCountries As New midCountry
With objCountries .UserName = gstrUserName .Password = gstrPassword End With cfrMain.DataSou rce = 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.OutOfMem oryException 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 application
(remoting example) that required .Net_Framework_1.1.
Since then I can only run console apps. If I try to run a
windows app with only a form, I get the following error
message:
|
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 sample application
(remoting example) that required .Net_Framework_1.1.
Since then I can only run console apps. If I try to run a
windows app with only a form, I get the following error
message:
|
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 couldn't find any info
on how to do this).
Here's the stack trace from cordbg:
Unhandled exception generated: (0x04719c94)
<System.Runtime.Remoting.RemotingException>
_className=<null>
_exceptionMethod=<null>
|
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 and on
Error Messag
Remote IP:66.122.242.6
Host:216.211.212.2
|
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 execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.OutOfMemoryException: Exception of type
System.OutOfMemoryException was thrown.
| |
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 MDI application. The first thing it does is to pop up a
little logon form which gathers and authenticates an SQL Server
|
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 during the Install phase.
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException'
was
|
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 add a separator button
to distance the new button from the old ones. When I do "show" on the
form (which is an mdi-child) I get the following exception:
System.OutOfMemoryException occurred in system.windows.forms.dll
|
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 IO.MemoryStream
=====Exception:
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException'
was
thrown.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |