How to get trace of NilobjectException

It has taken 2 days to fix NilobjecException of my Windows application.

I’m using RubberView to adjust user screen size. It works well.
However, I thought I fixed the Exception error but I noticed that I still have an issue(NilobjectException).

Apparently, I can see NilObjectException happnens on below code, but I’m not sure how I can get the stack trace information.
RubberViews1.SizAll(self, false, False) // in Resized event

  RubberViews1.SizAll(self, false, False)
  
  Exception err as OutOfBoundsException
    MsgBox "Tried to retype an object!"
  Exception err as NilObjectException
    
    Dim type As String = Introspection.GetType(err).Name
    Logging(type + EndOfLine + Join(err.Stack, EndOfLine))
    
    MsgBox "Tried to access a Nil object!"
    
  Exception err as RuntimeException  
    MsgBox "Another exception"

OR

  Try
    
    RubberViews1.SizAll(self, false, False)
    
    
  Catch exc As NilObjectException
    
    Dim type As String = Introspection.GetType(exc).Name
    Logging(type + EndOfLine + Join(exc.Stack, EndOfLine))
    
    
  End

In the Error pane of IDE, I can see 2 exceptions such as OutOfBoundsException and NilObjectException.
This issue only happens when I close my application with other windows by clicking ‘Minimize button of desktop’ and restore my application alone.
Then, application got crashed.

When I close my app and restore it itself without using ‘Desktop minimize button’, there is no issue. Very strange.

Question:
I need to get stack trace to contact Rubberview Support.
Can you let me know how I can get the trace of NilObjectException?

Thanks.

Join(exc.Stack, EndOfLine)

You’re already collecting the stack trace. Just save it to a file if you need to send it somewhere.

Instead of using Try catch as you do, better put this in App.UnhandledException. In case the NOE happens elsewhere :

Function UnhandledException(error As RuntimeException) As Boolean dim result() as string = error.Stack Dim t As TextOutputStream dim f as FolderItem = GetSaveFolderItem("text/plain", "stack.txt") If f <> Nil Then t = TextOutputStream.Create(f) for i as integer = 0 to result.Ubound-1 t.WriteLine(result(i)) next t.Close End If End Function

If you run this in the IDE, make sure break on exceptions is not checked.

You may also want to check if RubberViews1 is not nil. In the snippets you posted, that would be the only reason why an NOE would occur I can see.

First, I tried to put below code in App.UnhandledException after [Break on Exception] is not checked.
But, when Application got crashed, no stack.txt file is generated.

  dim result() as string = error.Stack
  Dim t As TextOutputStream
  dim f as FolderItem = GetSaveFolderItem("text/plain", "stack.txt")
  If f <> Nil Then
    t = TextOutputStream.Create(f)
    for i as integer = 0 to result.Ubound-1
      t.WriteLine(result(i))
    next
    t.Close
  End If  

I also tried below code with/witout [Break on Exception] in IDE, but no file is generated.
What is wrong…

  Try
    
    RubberViews1.SizAll(self, false, False)
    
    
  Catch error As Outofboundsexception
    
  dim result() as string = error.Stack
  Dim t As TextOutputStream
  dim f as FolderItem = GetSaveFolderItem("text/plain", "stack.txt")
  If f <> Nil Then
    t = TextOutputStream.Create(f)
    for i as integer = 0 to result.Ubound-1
      t.WriteLine(result(i))
    next
    t.Close
  End If  

  End

comment out the Rubberviews line. Does the NOE still happen?

if the NOE does not happen when the rubberviews line is commented out, try this:
Add a property to the window : bActivated as boolean

In the resize event, wrap the Rubberviews line in

if bActivated then RubberViews1.SizAll(self, false, False) end if

and in the window Activate event

if not bActivated then bActivated = true RubberViews1.SizAll(self, false, False) end if

It sounds as though the resizing is happening before your window is fully set up.
If one of the controls needs a picture for example, it may be trying to display it before it has been created…

When I comment RubberView, this OOB Exception doesn’t happen.
I think you assumption seems to be right.

ScreenShot

I tried to use Boolean flag, but I’m not successful now.
There are 2 ContainerControl under MainWindow, this issue happens on one of them first.
I don’t use any Picture object there, and I have checked the width/height value but there is no tiny one(eg. size of 2,3…).

As you said, I also think it is related to Resizing timing issue.
Let me try that Boolean flag method further.

Thank you.

Just in case:

In RubberView, normally it uses 3 events as following.

– Open
RubberViews1.Init(Self, 1594, 780)

–Resized / Resizing
RubberViews1.SizAll(self, false, False)

Thanks.

[quote=245025:@changwon lee]First, I tried to put below code in App.UnhandledException after [Break on Exception] is not checked.
But, when Application got crashed, no stack.txt file is generated.

dim result() as string = error.Stack
Dim t As TextOutputStream
dim f as FolderItem = GetSaveFolderItem(“text/plain”, “stack.txt”)
If f <> Nil Then
t = TextOutputStream.Create(f)
for i as integer = 0 to result.Ubound-1
t.WriteLine(result(i))
next
t.Close
End If [/quote]

I tested that before posting.
Try this :

dim result() as string = error.Stack for i as integer = 0 to result.Ubound-1 System.Debuglog(result(i)) next

It will display the stack in the Messages pane (third icon under the central pane of the IDE), you can then select it, right click ad copy, and paste into a text editor.

At any rate the issue seems to happen around RubberViews. Since you bought the encrypted version it won’t tell where it is inside it. You should send me your project by email so I debug further. Make sure to include all pictures and plugins.

Use

for i = 0 to result.Ubound

or you skip the last entry on the stack.

Oops. Thanks Tim.