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

Catastrophic failure

Dec 1, 2011 at 9:59 PM

Hi,

Thanks for creating this api.  I am experimenting with the example code that was provided below:

            using (TaskService ts = new TaskService())
            {
                // Display version and server state
                Version ver = ts.HighestSupportedVersion;
                bool newVer = (ver >= new Version(1, 2));
                Console.WriteLine("Highest version: " + ver);
                Console.WriteLine("Server: {0} ({1})", ts.TargetServer, ts.Connected ? "Connected" : "Disconnected");

                // Output all of the running tasks
                Console.WriteLine("Running tasks:");
                foreach (RunningTask rt in ts.GetRunningTasks(true))
                {
                    if (rt != null)
                    {
                        Console.WriteLine("+ {0}, {1} ({2})", rt.Name, rt.Path, rt.State);
                        if (ver.Minor > 0)
                            Console.WriteLine("  Current Action: " + rt.CurrentAction);
                    }
                }

...

and I get an error on this line:

foreach (RunningTask rt in ts.GetRunningTasks(true))

the ts.GetRunningTasks(true)) function throws this error:

 Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

I am using Visual Studio 2010 with .NET Framework 4.0 and I used Nuget to reference the files in my Windows Form project. 

1) Task Scheduler Managed Wrapper UI Library

2) Task Scheduler Managed Wrapper

Is there another reference I am not setting?  Any help would be appreciated.

Thanks.

 

Coordinator
Dec 2, 2011 at 3:47 PM

Which OS are you running this on? I doubt this is a configuration problem. It is more likely an operating system conflict.

Dec 2, 2011 at 5:31 PM
Hi,
Thanks for getting back to me.
It's Windows 7 Enterprise. Version 6.1 on a 32-bit system
Thanks,
Mike
Dec 5, 2011 at 6:43 PM

Here's something interesting, and offers a new clue.

I created a new project, and added a reference to the tasksched.dll that is found in my system32 directory.  Essentially, the code I run is this:

 

            TaskSchedulerClass sched = new TaskSchedulerClass();
            sched.Connect(null, null, null, null);
            if (sched.Connected)
            {
                foreach (IRunningTask rt in sched.GetRunningTasks(1))
                {
                    if (rt != null)
                    {
                        Console.WriteLine("+ {0}, {1} ({2})", rt.Name, rt.Path, rt.State);
                        Console.WriteLine("  Current Action: " + rt.CurrentAction);
                    }
                }
            }

the same line fails with the error

Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

when executing the line

"foreach (IRunningTask rt in sched.GetRunningTasks(1))"

So this problem exists with the native dll as well. Do you know where I should look for the operating system conflict?

thanks.

Coordinator
Dec 6, 2011 at 1:14 AM

The only guess I have is that it may be a permissions problem. When you run the "Task Scheduler" app from "Start Menu | Accessories | System Tools" and select the "Display All Running Tasks" item on the right, do you get the error or do you see the list or running tasks? If you're not an Administrator, try running that same app under that account and see if you get the error. Thanks for verifying that the problem is a system problem.

Dec 6, 2011 at 4:42 PM

Thanks for the reply.  That was a good idea to try the Task Scheduler app.  You are probably right about the permissions since our workstations have been recently rolled out and we have already seen some issues with permissions on other projects already.

I ran Task Scheduler as me, and then opened Task Scheduler as administrator, and it failed with the same error for both accounts.  So I cleared out my event viewer error log, and then reran the application with this API and looked at the event viewer for errors and found this:

Activation context generation failed for "C:\Windows\system32\conhost.exe". Dependent Assembly Microsoft.Windows.SystemCompatible,processorArchitecture="x86",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.7600.16816" could not be found. Please use sxstrace.exe for detailed diagnosis.

I don't know if this is the issue, but the conhost.exe file on my machine is version="6.1.7600.16816".  I wonder if this is the problem.  Why would a newer file not work?