dahall / TaskScheduler

Provides a .NET wrapper for the Windows Task Scheduler. It aggregates the multiple versions, provides an editor and allows for localization.
MIT License
1.22k stars 194 forks source link

TaskSchedulerEditor Issues #366

Closed dahall closed 6 years ago

dahall commented 6 years ago

ive got this code:

class TaskEditor {

        public TaskEditor() {
            DialogResult res;

            using (TaskService ts = new TaskService()) {
                Task t = ts.GetTask("command");
                TaskEditDialog editorForm = new TaskEditDialog(t, true, true);
                res = editorForm.ShowDialog();
            }
        }
    }

and everything seems fine there, except when it compiles it cant seem to find Microsoft.Win32.TaskSchedulerEditor.

Im using 1.7 and Visual Studio 2010. Ive added the .dll to my references and included the correct using directive, but it doesnt seem to want to work. Any ideas?

Originally posted: 2011-10-19T09:00:14

dahall commented 6 years ago

TaskSchedulerEditor is a separate assembly. On the downloads page for 1.7, you also need to extract all the files from the second download (TaskSchedulerEditor.zip) and reference the TaskSchedulerEditor.dll.

On another note, I'd make sure you have retrieved a valid task with the GetTask method before calling the editor.

if (t != null)

Originally posted: 2011-10-19T16:54:44

dahall commented 6 years ago

I have the same problem too.  If I want to use TaskService and TaskEditDialog I cannot do it because both have the same name.

Surely I am doing something basic wrong.

How can I use both assemblies at the same time, in the same .cs ?

Thanks.

Originally posted: 2011-11-25T13:29:29

dahall commented 6 years ago

Yes, in fact you mustuse both in order to use TaskEditDialog. You need to extract all the assemeblies from both downloads and then add them all to your project. There are support assemblies for the TaskSchedulerEditor.dll.

Originally posted: 2011-11-27T22:41:51

dahall commented 6 years ago

Sorry but I don't know what to do:

On my WinFormsApplication->References,  I have added;
  -Microsoft.Win32.TaskScheduler
  -Microsoft.Win32.TaskSchedulerEditor

In the source-cs code:

using Microsoft.Win32.TaskScheduler;

But when I try to use it:

TaskEditDialog editForm = new TaskEditDialog();

Both references to class TaskEditDialog are marked with error and when I try to compile it I get:

The type or namespace 'TaskEditDialog' could not be found (are you missing a ......);

Originally posted: 2011-11-29T09:16:37

dahall commented 6 years ago
  1. From the Downloads page, download the TaskScheduler.zip and TaskSchedulerEditor.zip files and extract all their contents to a folder on your system.
  2. From your project within Visual Studio add references to all the assemblies in that folder
    • Microsoft.Win32.TaskScheduler.dll
    • Microsoft.Win32.TaskSchedulerEditor.dll
    • AeroWizard.dll
    • GroupControls.dll
    • TimeSpan2.dll
    • CubicOrange.Windows.Forms.ActiveDirectory.dll
  3. You should then be able to use any of the classes either using the 'using' directive or by using the full name of the class.

OR

  1. Install NuGet from http://nuget.org/.
  2. Using NuGet from within Visual Studio, add references to the TaskScheduler and TaskSchedulerEditor packages
  3. Enjoy the benefit of having NuGet automatically keep all your assemblies up to date!

Originally posted: 2011-11-29T23:35:53

dahall commented 6 years ago

Thanks for your help David,

I have tried with your step-by-step instructions and with NuGet too, but TaskEditDialog is not "recognized" by my VS2010.  If I remove Microsoft.Win32.TaskScheduler from my "references" list then it right recognize TaskEditDialog but then it doesn't recognize the others (TaskService for example).

It is very curious because TaskEditDialog gets the 'ok-color' and when I compile it changes to underline-error-color.

Don't worry, perhaps any "collission" with DevExpress or another package.

Thanks again and regards.

Originally posted: 2011-11-30T09:57:40

dahall commented 6 years ago

Currently the namespaces of the TaskEditor are a bit confused (Assemblynamespace 'Microsoft.Win32.TaskSchedulerEditor', Defaultnamespace 'Microsoft.Win32.TaskScheduler') and the projects 'TaskEditor' and 'TaskService' are compiled for different dotNET-Versions (TaskEditor: dotNET 3.5, TaskService: dotNET 2.0, That's a bad choice.). Changing that, will solve the problem.

Originally posted: 2012-01-12T03:44:29

dahall commented 6 years ago

I have same problem too, i've solved downloading the sources and recompiling targeting .net 4 full, i'have also changed (as CKoewing noticed) the default namespace from 'Microsoft.Win32.TaskScheduler' to 'Microsoft.Win32.TaskSchedulerEditor'.

Originally posted: 2012-01-25T02:50:50

dahall commented 6 years ago

Same problem here.  How is this possibly working for anyone?  iLMax's suggestion did not work for me.  Does anyone have updated code for this?

Originally posted: 2012-02-27T10:42:09

dahall commented 6 years ago

Make sure the project supports at least .NET 3.5 then follow the steps in my earlier post adding all the assemblies referenced there. I have done this with a number of projects and know this works and doesn't cause namespace collisions. Having different .NET dependencies also is not a problem unless your main executable is .NET 4.0. Then you will see some initial load delays as the .NET 4.0 runtime loads the .NET 3.5 assemblies. You only need to use the single namespace:

using Microsoft.Win32.TaskScheduler;

If you are missing the controls in the Toolbox, you need to manually add those from the assemblies.

Originally posted: 2012-02-27T17:05:47

dahall commented 6 years ago

I'm not sure what else to try.  I guess it must be something on my end, but I don't know what.  I am going to look for another library.  If I solve the issue, I'll post something here.  This is what I did:

  1. Extract files from TaskScheduler.zip, and TaskSchedulerEditor.zip (6 dll, 5 xml)
  2. Add references to all to my project.
  3. Add System.Windows.Forms as a reference (Otherwise I avoid this).
  4. Add "using Microsoft.Win32.TaskScheduler;" to usings.
  5. Create task service, and loop through tasks, searching for a specific one (called 't').
  6. Add the following lines of code:      
       TaskEditDialog editorForm = new TaskEditDialog(t, true, true);   editorForm.ShowDialog();

The "TaskEditDialog" shows in light blue (my 'OK' color).  No red/blue squigglies.
   If I type "TaskEditD" and invoke intellisense it completes the rest of the  word.
   if I click on "TaskEditDialog" and press F12 it goes to the definition's metadata.

  1. Build. Instantly get an error:
         "The type or namespace name 'TaskEditDialog' could not be found (are you missing a using directive or an assembly reference?)"

  2. The word now appears with a blue squiggly under it.

I also tried changing the namespace of the editor (and all supporting files for it), and the targeted version to .Net 4.0.  No luck.

Originally posted: 2012-02-28T06:51:24

dahall commented 6 years ago

I have just included a very simple VS2010 C# project that works. It is at the bottom of this link: http://taskscheduler.codeplex.com/wikipage?title=Install. I hope this helps.

Originally posted: 2012-02-28T09:46:57