This project has moved. For the latest updates, please go here.

View Tasks: Object reference not set to an instance of an object

Sep 29, 2010 at 3:09 PM

Hi Guys,

 

Im using the latest version of Task Scheduler 1.5 B3. Im trying to read out trough asp.net VB the scheduled tasks of some remote windows 2003 SP2 servers.

This is the script i use

 

Dim ts As New TaskService("\\" & Computer, Username, , Password)

For Each Task In ts.RootFolder.Tasks

     Label1.Text = "|" & Task.Name & "|" & Task.State

Next

 

Im getting the following error:

Object reference not set to an instance of an object

[NullReferenceException: Object reference not set to an instance of an object.] Microsoft.Win32.TaskScheduler.V2TaskEnumerator..ctor(TaskFolder folder, IRegisteredTaskCollection iTaskColl) +57 Microsoft.Win32.TaskScheduler.TaskCollection.GetEnumerator() +106 Systeem_Info._Default.retrieveTask(ManagementScope scope, DataTable dt, String Computer) in Default.aspx.vb:124 Systeem_Info._Default.Page_Load(Object sender, EventArgs e) in Default.aspx.vb:53 System.Web.UI.Control.OnLoad(EventArgs e) +91 System.Web.UI.Control.LoadRecursive() +74 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

 

Coordinator
Oct 20, 2010 at 6:15 PM

Check first that ts has been instantiated correctly and then that ts.RootFolder also is valid before your For Each call and respond appropriately. The error you are getting implies that one of those two variables does not have an object associated with it.