Click here to Skip to main content
13,193,064 members (84,657 online)
Rate this:
Please Sign up or sign in to vote.
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 7:02am
Updated 6-Sep-12 8:21am
Wes Aday104.2K
Mehdi Gholam 6-Sep-12 13:22pm
It's very hard to comment with the little information you supplied, so we are stumped too.
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 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 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 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171017.2 | Last Updated 6 Sep 2012
Copyright © CodeProject, 1999-2017
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