LogonTrigger delay property missing?

Aug 5, 2011 at 7:59 PM

Subject says it all. imported via add library package reference.

VS 2010 VB.net project

i can create a LogonTrigger and add it to a task, but the delay property gives a 'delay' is not a member of Microsoft.Win32.TaskScheduler.Trigger error.

                    td = taskService.NewTask()
                    td.RegistrationInfo.Description = currentPublication + "Sync Task : scheduled task to fire sql replication."
                    td.RegistrationInfo.Author = "XXXXXX"
                    td.RegistrationInfo.Date = Now
                    tLTrigger = New LogonTrigger
                    'tLTrigger.Delay = TimeSpan.FromMinutes(5)
                    tLTrigger.Enabled = False
                    tLTrigger.ExecutionTimeLimit = TimeSpan.Zero
                    tLTrigger.Repetition.Duration = TimeSpan.Zero
                    tLTrigger.Repetition.Interval = TimeSpan.FromMinutes(15)
                    td.Triggers.Add(tLTrigger)
                    td.Settings.RunOnlyIfNetworkAvailable = True
                    td.Settings.NetworkSettings.Name = networkName
                    td.Settings.NetworkSettings.Id = networkRegGUID
                    td.Settings.StartWhenAvailable = True
                    td.Settings.StopIfGoingOnBatteries = False
                    td.Settings.ExecutionTimeLimit = TimeSpan.FromHours(2)
                    td.Settings.Compatibility = TaskCompatibility.V2
                    td.Settings.MultipleInstances = TaskInstancesPolicy.IgnoreNew

                    td.Actions.Add(New ExecAction(syncBatchPath + "\sync" + currentPublication + "Merge.bat"))
                    taskService.GetFolder(syncFolderName).RegisterTaskDefinition(currentPublication + "Sync", td, TaskCreation.Create, replicationID, replicationPW, TaskLogonType.Password)

version 1.6.4219.15519 of the Microsoft.Win32.TaskScheduler dll.
any help would be great.
nathan
Coordinator
Aug 5, 2011 at 11:38 PM

LogonTrigger, under V2 (Win Vista and later), does have a Delay property. Please confirm you are using a later OS version. If you are, please post the exact text from the exception.

Aug 6, 2011 at 1:34 AM

windows 7 ultimate x64 - visual studio professional -  .net 4 windows application

VS info

Microsoft Visual Studio 2010
Version 10.0.30319.1 RTMRel
Microsoft .NET Framework
Version 4.0.30319 RTMRel

Installed Version: Professional

intellisense does not have the Delay property. all other properties are listed.

there is a compile error of (from error list)-

Error 1 'Delay' is not a member of 'Microsoft.Win32.TaskScheduler.Trigger'. C:\Users\Gamer\documents\visual studio 2010\Projects\WindowsApplication1\WindowsApplication1\Form1.vb 8 9 WindowsApplication1

thats the only error i get

Coordinator
Aug 6, 2011 at 6:30 AM

I'm not a VB expert, but I think you only need to force the type of the tLTrigger variable:

Dim tLTrigger As LogonTrigger = New LogonTrigger()

Or, you need to cast the tLTrigger variable to a LogonTrigger before calling the Delay property. It appears that right now it is the parent class Trigger which does not have that property.

Aug 6, 2011 at 2:44 PM

I should have cast it as a logontrigger instead of the standard trigger.

thanks much that worked