Object reference not set to an instance of an object.

secaro

Member
Joined
Sep 3, 2006
Messages
6
Programming Experience
Beginner
Im trying to compile a sample application named Servant. The source can be found here -> http://www.codeproject.com/vbscript/Generic_P2P_Architecture.asp

The project contains two projects: ConnectionMgr and Servant.

ConnectionMgr compiles ok but when i try to compile Servant i get an error that says "Object reference not set to an instance of an object." on this line:
strAddy = pConfig.selectSingleNode("./config/connectionmgr").text

Does anyone have any idea about how to solve this ?:confused:

Error report:
---------------------------------------------
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="Servant"
StackTrace:
at Servant.frmServant.frmServant_Load(Object eventSender, EventArgs eventArgs) in C:\Documents and Settings\Laptop\Mis documentos\Utvikling\p2p - stream\This_gener171835392004\PlanetAPI_P2PDemo\servant\Servant.NET\frmServant.vb:line 51
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Servant.frmServant.Main() in C:\Documents and Settings\Laptop\Mis documentos\Utvikling\p2p - stream\This_gener171835392004\PlanetAPI_P2PDemo\servant\Servant.NET\frmServant.Designer.vb:line 1
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
----------------------------------------------------
 
I would guess that there is no node named "./config/connectionmgr", so selectSingleNode is returning Nothing. You're trying to access the 'text' property of a null reference and BOOM! Exception.

You need to learn how to debug so you can figure this sort of thing out for yourself. Null reference exceptions are some of the easiest to track down. When the debugger breaks on that line you simply test each reference on the line to see which is Nothing. You could select 'pConfig.selectSingleNode("./config/connectionmgr")' and right-click and select Quick Watch and it will open a dialogue that tells you what that expression retruns.
 
Back
Top