Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / April 2005

Tip: Looking for answers? Try searching our database.

best debug / perfmon options to drilldown to find error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
chris yoker - 05 Apr 2005 11:01 GMT
hiya,
I have winforms app that contains  buttons.
Any time that I click on any of the  buttons, I get an error:

<error>
An unhandled exception of type 'System.NullReferenceException' occurred in
system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.
<\error>

This error occurs BEFORE, the "Button_click" event fires.

However, despite the fact that I set breakpoints at:
1)  "btnClose_Click" event
2) "frmProduct_Closed" event
3) "frmProduct_Closing" event

The app goes straight into a 'System.NullReferenceException' error.The
breakpoints do not even reach the "btnClose_Click" event.I know for a fact
that debugging works on this app.
I am using vis studio 2003 + perfmon
Also, I have added a ".net CLR memory" log to perfmon.

Can anyone suggest which "debug" options will help me drilldown and find
the error, eg callStack, threads?..ATM, I am only familiar with "watch" and
"breakpoints"

To be honest, I am dancing round in the dark.

many thanks,
yogi
john conwell - 05 Apr 2005 17:05 GMT
Hey Chris,
thats a good one.  could you post the stack trace?  that will tell you
exactly where the exception is being thrown.  

What I do in situations like this where an exception is being thrown
somewhere besides my code (in someone else's  compiled assembly) is to look
at the stack trace and figure out what class and method the exception is
being thrown from.  Then i use Reflector to look at the code of that method
and see what could possibly be the problem.

> hiya,
> I have winforms app that contains  buttons.
[quoted text clipped - 28 lines]
> many thanks,
> yogi
Mike Goatly - 05 Apr 2005 17:29 GMT
Hi,

The first thing I'd do is set the CLR to break into code whenever an
exception is thrown - that way you'll see exactly what's throwing the error
(unless it's from someone elses dll - but you should still be able to see
what's causing it in the call stack - I'll explain that in a mo.)

To set the CLR to "break on all errors" you need to go to the Exceptions
window (Debug->Exceptions or Ctrl-Alt-E) , click on the "Common Language
Runtime Exceptions" node in the exceptions list, and change the "When an
exception is thrown" option to "Break into the debugger"

Now run the code again...

When you get the exception, have a look at the call-stack window.  (if it's
not visible you can get at it from Debug->Windows->Call Stack)  At the top of
the list is the method the exception was raised from.  That might provide
some insight into what's going wrong...

Failing that, if you could post the callstack here, someone here might be
able to help a bit more.

Cheers,
Mike

> hiya,
> I have winforms app that contains  buttons.
[quoted text clipped - 28 lines]
> many thanks,
> yogi
chris yoker - 07 Apr 2005 09:14 GMT
hiya, ta for the replies..
I followed the advice and tracked it down to a weird 3rd party data
corruption error.Great advice :-)

yogi
jasmin Col - 15 Apr 2005 07:08 GMT
Hi Mike,
I have the same problem  as him.  I have a wrapper class that is using a
hidden form to wrap ActiveX.  I am calling the wrapper from another
executable using new, but Iam getting System.NullReference Exception
object reference not set to an instance of an object (it says the
problem is coming from system.windows.forms.dll) . I am new to C##. I
followed your steps to find the stack trace and this is what I got. Any
ideas of what it means?

-    this    {System.Windows.Forms.AxHost.ConnectionPointCookie}    System.Window
s.Forms.AxHost.ConnectionPointCookie
    System.Object    {System.Windows.Forms.AxHost.ConnectionPointCookie}    Syste
m.Object
-    connectionPoint    {System.__ComObject}    System.Windows.Forms.UnsafeNative
Methods.IConnectionPoint
+    [System.__ComObject]    {System.__ComObject}    System.__ComObject
    cookie    0x621ff90    int
-    this    {System.Windows.Forms.AxHost.ConnectionPointCookie}    System.Window
s.Forms.AxHost.ConnectionPointCookie
    System.Object    {System.Windows.Forms.AxHost.ConnectionPointCookie}    Syste
m.Object
+    connectionPoint    {System.__ComObject}    System.Windows.Forms.UnsafeNative
Methods.IConnectionPoint
    cookie    0x621ff90    int
-    ((System.Windows.Forms.Form)(this))    {System.Windows.Forms.AxHost.Conne
ctionPointCookie}    System.Windows.Forms.Form
+    [System.Windows.Forms.AxHost.ConnectionPointCookie]    {System.Windows.Fo
rms.AxHost.ConnectionPointCookie}    System.Windows.Forms.AxHost.Connection
PointCookie
+    System.Windows.Forms.ContainerControl    {System.Windows.Forms.AxHost.Con
nectionPointCookie}    System.Windows.Forms.ContainerControl
    AcceptButton    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.IButtonControl
    Active    <error: an exception of type: {System.ArgumentException}
occurred>    bool
    ActiveForm    <undefined value>    System.Windows.Forms.Form
    ActiveMdiChild    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.Form
    AllowTransparency    <error: an exception of type:
{System.ArgumentException} occurred>    bool
    AutoScale    <error: an exception of type: {System.ArgumentException}
occurred>    bool
    AutoScaleBaseSize    <error: an exception of type:
{System.ArgumentException} occurred>    System.Drawing.Size
+    autoScaleBaseSize    {Width=0x490074 Height=0x17001d}    System.Drawing.Size
    AutoScroll    <error: an exception of type: {System.ArgumentException}
occurred>    bool
    BackColor    <error: an exception of type: {System.ArgumentException}
occurred>    System.Drawing.Color
    calledCreateControl    true    bool
    calledMakeVisible    false    bool
    calledOnLoad    true    bool
    CancelButton    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.IButtonControl
    ClientSize    <error: an exception of type: {System.ArgumentException}
occurred>    System.Drawing.Size
    ControlBox    <error: an exception of type: {System.ArgumentException}
occurred>    bool
    CreateParams    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.CreateParams
+    ctlClient    {System.ComponentModel.ReflectPropertyDescriptor}    System.Win
dows.Forms.MdiClient
+    DefaultIcon    {System.Drawing.Icon}    System.Drawing.Icon
+    defaultIcon    {System.Drawing.Icon}    System.Drawing.Icon
    DefaultImeMode    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.ImeMode
+    defaultRestrictedIcon    {System.Drawing.Icon}    System.Drawing.Icon
+    DefaultRestrictedIcon    {System.Drawing.Icon}    System.Drawing.Icon
    DefaultSize    <error: an exception of type: {System.ArgumentException}
occurred>    System.Drawing.Size
    DesktopBounds    <error: an exception of type: {System.ArgumentException}
occurred>    System.Drawing.Rectangle
    DesktopLocation    <error: an exception of type:
{System.ArgumentException} occurred>    System.Drawing.Point
    dialogResult    0x9473dd8    System.Windows.Forms.DialogResult
    DialogResult    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.DialogResult
    EVENT_ACTIVATED    {System.Object}    System.Object
    EVENT_CLOSED    {System.Object}    System.Object
    EVENT_CLOSING    {System.Object}    System.Object
    EVENT_DEACTIVATE    {System.Object}    System.Object
    EVENT_INPUTLANGCHANGE    {System.Object}    System.Object
    EVENT_INPUTLANGCHANGEREQUEST    {System.Object}    System.Object
    EVENT_LOAD    {System.Object}    System.Object
    EVENT_MAXIMIZEDBOUNDSCHANGED    {System.Object}    System.Object
    EVENT_MAXIMUMSIZECHANGED    {System.Object}    System.Object
    EVENT_MDI_CHILD_ACTIVATE    {System.Object}    System.Object
    EVENT_MENUCOMPLETE    {System.Object}    System.Object
    EVENT_MENUSTART    {System.Object}    System.Object
    EVENT_MINIMUMSIZECHANGED    {System.Object}    System.Object
    FormBorderStyle    <error: an exception of type:
{System.ArgumentException}
occurred>    System.Windows.Forms.FormBorderStyle
+    formState    {System.Collections.Specialized.BitVector32}    System.Collecti
ons.Specialized.BitVector32
+    FormStateAllowLayered    {System.Collections.Specialized.BitVector32.Sect
ion}    System.Collections.Specialized.BitVector32.Section
+    FormStateAutoScaling    {System.Collections.Specialized.BitVector32.Secti
on}    System.Collections.Specialized.BitVector32.Section
+    FormStateBorderStyle    {System.Collections.Specialized.BitVector32.Secti
on}    System.Collections.Specialized.BitVector32.Section
+    FormStateControlBox    {System.Collections.Specialized.BitVector32.Sectio
n}    System.Collections.Specialized.BitVector32.Section
+    FormStateHelpButton    {System.Collections.Specialized.BitVector32.Sectio
n}    System.Collections.Specialized.BitVector32.Section
+    FormStateIconSet    {System.Collections.Specialized.BitVector32.Section}   
System.Collections.Specialized.BitVector32.Section
+    FormStateIsActive    {System.Collections.Specialized.BitVector32.Section}
    System.Collections.Specialized.BitVector32.Section
+    FormStateIsRestrictedWindow    {System.Collections.Specialized.BitVector3
2.Section}    System.Collections.Specialized.BitVector32.Section
+    FormStateIsRestrictedWindowChecked    {System.Collections.Specialized.Bit
Vector32.Section}    System.Collections.Specialized.BitVector32.Section
+    FormStateIsTextEmpty    {System.Collections.Specialized.BitVector32.Secti
on}    System.Collections.Specialized.BitVector32.Section
+    FormStateIsWindowActivated    {System.Collections.Specialized.BitVector32
.Section}    System.Collections.Specialized.BitVector32.Section
+    FormStateKeyPreview    {System.Collections.Specialized.BitVector32.Sectio
n}    System.Collections.Specialized.BitVector32.Section
+    FormStateLayered    {System.Collections.Specialized.BitVector32.Section}   
System.Collections.Specialized.BitVector32.Section
+    FormStateMaximizeBox    {System.Collections.Specialized.BitVector32.Secti
on}    System.Collections.Specialized.BitVector32.Section
+    FormStateMdiChildMax    {System.Collections.Specialized.BitVector32.Secti
on}    System.Collections.Specialized.BitVector32.Section
+    FormStateMinimizeBox    {System.Collections.Specialized.BitVector32.Secti
on}    System.Collections.Specialized.BitVector32.Section
+    FormStateRenderSizeGrip    {System.Collections.Specialized.BitVector32.Se
ction}    System.Collections.Specialized.BitVector32.Section
+    FormStateSetClientSize    {System.Collections.Specialized.BitVector32.Sec
tion}    System.Collections.Specialized.BitVector32.Section
+    FormStateShowWindowOnCreate    {System.Collections.Specialized.BitVector3
2.Section}    System.Collections.Specialized.BitVector32.Section
+    FormStateSizeGripStyle    {System.Collections.Specialized.BitVector32.Sec
tion}    System.Collections.Specialized.BitVector32.Section
+    FormStateStartPos    {System.Collections.Specialized.BitVector32.Section}
    System.Collections.Specialized.BitVector32.Section
+    FormStateSWCalled    {System.Collections.Specialized.BitVector32.Section}
    System.Collections.Specialized.BitVector32.Section
+    FormStateTaskBar    {System.Collections.Specialized.BitVector32.Section}   
System.Collections.Specialized.BitVector32.Section
+    FormStateTopMost    {System.Collections.Specialized.BitVector32.Section}   
System.Collections.Specialized.BitVector32.Section
+    FormStateWindowState    {System.Collections.Specialized.BitVector32.Secti
on}    System.Collections.Specialized.BitVector32.Section
    HasMenu    <error: an exception of type: {System.ArgumentException}
occurred>    bool
    HelpButton    <error: an exception of type: {System.ArgumentException}
occurred>    bool
+    icon    {...}    System.Drawing.Icon
    Icon    <error: an exception of type: {System.ArgumentException}
occurred>    System.Drawing.Icon
    IsMdiChild    <error: an exception of type: {System.ArgumentException}
occurred>    bool
    IsMdiChildAndNotVisible    <error: an exception of type:
{System.ArgumentException} occurred>    bool
    IsMdiContainer    <error: an exception of type: {System.ArgumentException}
occurred>    bool
    IsRestrictedWindow    <error: an exception of type:
{System.ArgumentException} occurred>    bool
    KeyPreview    <error: an exception of type: {System.ArgumentException}
occurred>    bool
    MaximizeBox    <error: an exception of type: {System.ArgumentException}
occurred>    bool
    MaximizedBounds    <error: an exception of type:
{System.ArgumentException} occurred>    System.Drawing.Rectangle
    MaximumSize    <error: an exception of type: {System.ArgumentException}
occurred>    System.Drawing.Size
    MdiChildren    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.Form[]
    MdiParent    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.Form
    MdiParentInternal    <error: an exception of type:
{System.ArgumentException} occurred>    System.Windows.Forms.Form
    Menu    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.MainMenu
    MergedMenu    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.MainMenu
    MinimizeBox    <error: an exception of type: {System.ArgumentException}
occurred>    bool
    MinimumSize    <error: an exception of type: {System.ArgumentException}
occurred>    System.Drawing.Size
    Modal    <error: an exception of type: {System.ArgumentException}
occurred>    bool
    Opacity    <error: an exception of type: {System.ArgumentException}
occurred>    double
    OpacityAsByte    <error: an exception of type: {System.ArgumentException}
occurred>    byte
    OwnedForms    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.Form[]
    Owner    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.Form
    OwnerInternal    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.Form
    ParentInternal    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.Control
    PropAcceptButton    0x0    int
    PropActiveMdiChild    0x11    int
    PropCancelButton    0x1    int
    PropCurMenu    0x6    int
    PropDefaultButton    0x2    int
    PropDialogOwner    0x3    int
    PropDummyMenu    0x5    int
    PropFormMdiParent    0x10    int
    PropMainMenu    0x4    int
    PropMaximizedBounds    0xa    int
    PropMaxTrackSizeHeight    0xf    int
    PropMaxTrackSizeWidth    0xe    int
    PropMergedMenu    0x7    int
    PropMinTrackSizeHeight    0xd    int
    PropMinTrackSizeWidth    0xc    int
    PropOpacity    0x12    int
    PropOwnedForms    0x9    int
    PropOwnedFormsCount    0xb    int
    PropOwner    0x8    int
    PropSecurityTip    0x14    int
    PropTransparencyKey    0x13    int
+    restoredWindowBounds    {X=0x80103 Y=0x0 Width=0xc315f34
Height=0x943d720}    System.Drawing.Rectangle
    restoredWindowBoundsSpecified    0x945f2b0    System.Windows.Forms.BoundsSpec
ified
    securitySite    "&#8076;&#1226;&#58604;&#159;&#58604;&#159;\0\0&#29824;?\0
\0\0\0&#11607;&#38333;\0\0\0\0\0\0\0\0\0\0\0\0&#58644;&#159;&#2748;?&#77
64; \0\0\0\0&#29296;?\0\0\0\0\0"    string
    securityZone    "&#1596;&#31543;&#44172;&#159;&#44172;&#159;&#7316;
&#7272;
\0\0\0\0&#42363;&#35692;&#257;\0\0\0\0\0\0\0\0\0\0\0&#38712;&#159;&#4422
0;&#159;\0\0\0\0&#40620;&#159;&#44108;&#159;&#44132;&#159;\0\0\0\0\0\0\0
\0F\0\0"    string
    ShowInTaskbar    <error: an exception of type: {System.ArgumentException}
occurred>    bool
    ShowParams    <error: an exception of type: {System.ArgumentException}
occurred>    int
    Size    <error: an exception of type: {System.ArgumentException}
occurred>    System.Drawing.Size
    SizeGripSize    0x10    int
    SizeGripStyle    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.SizeGripStyle
+    smallIcon    {...}    System.Drawing.Icon
    StartPosition    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.FormStartPosition
    TabIndex    <error: an exception of type: {System.ArgumentException}
occurred>    int
    TopLevel    <error: an exception of type: {System.ArgumentException}
occurred>    bool
    TopMost    <error: an exception of type: {System.ArgumentException}
occurred>    bool
    TransparencyKey    <error: an exception of type:
{System.ArgumentException} occurred>    System.Drawing.Color
    updateMenuHandlesDeferred    true    bool
    updateMenuHandlesSuspendCount    0x0    byte
    useMdiChildProc    false    bool
    userWindowText    "&#1596;&#31543;&#53096;&#159;&#53096;&#159;&#6528;
&#6484;
\0\0\0\0&#535;&#2952;&#257;\0\0\0\0\0\0\0\0\0\0\0&#38712;&#159;&#8280;&#
151;\0\0\0\0&#41676;&#159;&#53032;&#159;&#53056;&#159;\0\0\0\0\0\0\0\0F\
0\0"    string
    WindowState    <error: an exception of type: {System.ArgumentException}
occurred>    System.Windows.Forms.FormWindowState
    WindowText    <error: an exception of type: {System.ArgumentException}
occurred>    string
+    this    {System.Windows.Forms.AxHost.ConnectionPointCookie}    System.Window
s.Forms.AxHost.ConnectionPointCook

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.