Cannot get rid of these exceptions

  • Thread starter Thread starter Patrick Penet
  • Start date Start date
P

Patrick Penet

Again I need your help, cuz I'm out of idea !

I get an error at runtime at the indicated line :
System.NullReferenceException occured in MyApp.exe

If I continue, I get :
System.TypeInitializationException occured in unknown module ...

Help on these matters is chinese to me.

In a standard module :
'====
Public tbxOtherPilotFullPath As Collection = New Collection

Sub tbxOPENTBXCFG(ByVal sMyFullPath As String)
Dim t As String
Dim SR As StreamReader = New StreamReader(sMyFullPath)

While Not t = vbNullString
t = SR.ReadLine()
tbxOtherPilotFullPath.Add(t) '<=== Error here !!!
End While

SR.Close()
End Sub
'====

When hovering on the variable t, it shows the expected string.
I have been feeding collections many times without a problem
so I can't understand why it don't work this time.

Thank you for any help.
Patrick
 
Because the call to the sub was made from MyForm Sub New()
I just discovered (finally) this was the *REAL* entry point of my app
before Sub Main() although indicated in the app property page,
therefore the collection was never initialized.

The teaching is 'I will never again call an external sub from New()'
(it took me a while !) ;-(
P.
 
Back
Top