Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
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.


Update:


Here is the code that is throwing the error

VB
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)
        SetLogging()
        databaseMgr = database
End Sub
...
End Class

IDatabase and ILog exist in the same assembly..

Hope this help
Posted
Updated 6-Sep-12 8:21am
v4
Comments
Mehdi Gholam 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 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... :-)
--SA

1 solution

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.
 
Share this answer
 
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900