Why is it that when I am debugging an application that has a call to
Form.ActiveForm , if I set a breakpoint before the call then when I reach
that statement a NullReferenceEx ception is thrown, but if the breakpoint was
set following the call to Form.ActiveForm , then I can continue the debug
session without a problem?
Thanks,
Dennis 2 2047
Dennis,
Probably because it tries to get a form from the active window handle.
If the current window is the debug window, then it doesn't have a managed
window to map to =)
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Dennis C. Drumm" <an*********@co mmunity.nospam> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. .. Why is it that when I am debugging an application that has a call to Form.ActiveForm , if I set a breakpoint before the call then when I reach that statement a NullReferenceEx ception is thrown, but if the breakpoint was set following the call to Form.ActiveForm , then I can continue the debug session without a problem?
Thanks,
Dennis
Nicholas:
I thought it might be something like that, I just wasn't sure whether or not
the vs.net environment could compensate for that in debug mode.
Thnaks,
Dennis
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:OZ******** *****@TK2MSFTNG P12.phx.gbl... Dennis,
Probably because it tries to get a form from the active window handle. If the current window is the debug window, then it doesn't have a managed window to map to =)
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Dennis C. Drumm" <an*********@co mmunity.nospam> wrote in message news:%2******** ********@tk2msf tngp13.phx.gbl. .. Why is it that when I am debugging an application that has a call to Form.ActiveForm , if I set a breakpoint before the call then when I reach that statement a NullReferenceEx ception is thrown, but if the breakpoint was set following the call to Form.ActiveForm , then I can continue the debug session without a problem?
Thanks,
Dennis
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sherwood |
last post by:
Greetings,
I have the following code (which displays a second form), but it is not
working as expected. I want to close the calling form after the dismissing
the second form. However, the second form never displays with the code I
have below. Any suggestions? .
ActiveForm.Hide();
frmInstructions frmInstructions = new frmInstructions();
frmInstructions.Show();
|
by: Ignacio X. Domínguez |
last post by:
Hi. I have created a component (System.ComponentModel.Component) that I
place on a form. Is there a way of obtaining the Form.Handle of the form
where I have placed my component?
Thank you
|
by: Eh |
last post by:
I have a project containing a WindowsForm and a module and
need to set the text property on a label control on the
form from the module.
here's the code (from MS Framework .Net Doc):
Dim test as Form2 = Form2.ActiveForm
Dim i As Integer
For i = 0 To test.Controls.Count - 1
MsgBox(test.Controls(i).Name)
Next
|
by: Hugh |
last post by:
Hi,
I used following sentex to change form width:
MainForm.ActiveForm.width = 200
However, a error was generated: An unhandled exception of
type 'System.NullReferenceException' occurred. I am
confused. The same command works for other applications.
Any idea.
|
by: ramhog |
last post by:
Hello all,
I have a C# control that is housed on a form that was created in VB 6.
There are some activities I want to do only if the control is on the
ActiveForm. However, since the form is a VB 6 form when I call
Form.ActiveForm I get a null back, even though I can see the form is
the active windows form. Is there a good way to get the ActiveForm in
this scenario?
Thank you.
| |
by: Jim Madsen |
last post by:
OK--Beginner question--
I have a project with one form -- Form1. To change the text, why can't
I use "Form1.Text = something"? Instead I have to use
"Form1.ActiveForm.Text = Something". As an exercise, I rewrote a timer
app that I wrote in VB 5.0. You set the time, and when it runs, it
minimizes until the time is up, and then pops back up again and gives an
alerting sound. In VB 5.0, I was able to write the time to the forms
text...
|
by: Peter Morris |
last post by:
Form activeForm = System.Windows.Forms.Form.ActiveForm;
Form activeMdiChildForm = activeForm.ActiveMdiChild;
This code is in a component of mine and is triggered from various places
within my application. My problem is that when I run the app
Form.ActiveForm is always set, whereas when I am stepping through code using
the debugger it is always null. This results in a NullReferenceException
|
by: John Brown |
last post by:
Hi there,
Does anyone know how to (generically) determine the currently active form for an application using a "static" function (so I can call it from anywhere). There is no offiical way I've been able to find so I've written the following for starters:
public static Form GetActiveForm()
{
// Returns null for an MDI app
Form activeForm = Form.ActiveForm;
if (activeForm == null)
{
|
by: Emre Sevinc |
last post by:
Hello,
I have a strange situation. I create a very simple Windows Forms
application and place the code below however even though I place
breakpoints in various event handling points VS.NET 2005 only enters
the breakpoint for the button but not for the form. Am I missing
something? Why don't the events for my form Form1 have any effect?
Form1.cs:
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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: 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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |