Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: Win2003 Exception VB.NET .NET4 , +
I have a small .bat program that runs at night using VB.NET 4.0. The job use to run on a Window XP Service Pack 3. I tried to migrate the application to a Windows 2003 Service 3. The application failed stating System.Null exception. I followed the code and it seems to fail on initializing one of my class.
I used a .NET decompiler and I know the class is part of the executable, same assembly as the .exe. The same application works on Windows 7 and Window XP.
I am stumped.


Here is the code that is throwing the error
Public gobjLog as Log
Public Function Main(ByVal CmdArgs() As String) As Integer
gobjLog = New Log(databaseMgr)
End Function
Sample of the Log class
Option Strict On
Option Explicit On
Friend Class Log
    Implements ILog, IDisposable
Public Sub New(ByRef database As IDatabase)
        databaseMgr = database
End Sub
End Class
IDatabase and ILog exist in the same assembly..
Hope this help
Posted 6-Sep-12 8:02am
Edited 6-Sep-12 9:21am
Wes Aday94.3K
Mehdi Gholam at 6-Sep-12 13:22pm
It's very hard to comment with the little information you supplied, so we are stumped too.
Sergey Alexandrovich Kryukov at 6-Sep-12 13:28pm
Please be advised that my access to your hard drive is somewhat limited due to the start of first semester at schools... :-)

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I'll assume that "SystemNull exception" actually means "Object not set to an instance of an object".
All you have to do is step through the code where it bombs and check to see which one of your objects returned Nothing. Your code is making the assumption that some call that is supposed to return an object returned an object when, in fact, it didn't. Then you tried to set a property or execute a method on that object, resulting in the error.
Since this appears to have something to do with logging, you might be trying to open a log file in a folder that the user does not have create/write permissions to. Depending on how your logging class' exception handling is setup, it may cause this problem.
cple82309 at 13-Sep-12 16:55pm
I was able to create a file and write using the same user permission that is running the process, which happens to have the same authority as system administrator.
I traced through the source and it seems to be bombing at calling the method SetLogging(). None of my constructor's console.write line is writing out.
Dave Kreskowiak at 14-Sep-12 7:44am
OK, then you have to step into SetLogging and see what it's doing. You still need to dins where that error is coming from.
Come on! This is not rocket science!
cple82309 at 15-Sep-12 18:11pm
I have a console.write before the method SetLogging() and that console.write did not write anything. It's almost as if the class is not being initiated. Remember, the same class and method works on an XP and Windows 7.
Dave Kreskowiak at 15-Sep-12 22:46pm
If the Console.Write does write anything in a Console application, then the code just before you execute that "New Log(databaseManager)" failed. You need to trace through that code and find out where you're code is assuming it's successfully creating an object, but it really hasn't. Youre code never checks to see if it got the object (If ... Is Nothing) before you try to use it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 520
1 Maciej Los 205
2 Suvendu Shekhar Giri 159
3 Peter Leow 140
4 Kornfeld Eliyahu Peter 133
0 Sergey Alexandrovich Kryukov 9,623
1 OriginalGriff 8,895
2 Peter Leow 5,044
3 Kornfeld Eliyahu Peter 3,333
4 Maciej Los 2,561

Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 6 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100