BadImageFormatException when trying to use TaskScheduler on Any CPU

714 Views Asked by At

We are trying to change a program from 32-bit to Any CPU. The program is in C# on .NET 3.5.

We are using Windows Task Scheduler COM wrapper.

The application compiles but when we try to run it on a 64-bit platform we are getting the following error:

BadImageFormatException: Could not load file or assembly 'Interop.TaskScheduler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4b71cab8d8e4499f' or one of its dependencies. An attempt was made to load a program with an incorrect format.

UPDATE: We created a new C# project in Any CPU, with TaskScheduler as a Reference, and with a very simple 2-line code (create an instance of TaskSchedulerClass and write a line to the console). We ran it on the same 64-bit platform, and it worked. However, the entire application is still not working. Thank you for your help.

3

There are 3 best solutions below

0
On

Since its a COM interop assembly, likely its only 32-bit. You have to keep your project as 32-bit.

0
On

your assemly can work only 32-bit, try find x64 version or alternative assembly

0
On

You can use WMI to schedule tasks via the standard managed interface to avoid using the COM component which restricts you to running as 32-bit.

http://msdn.microsoft.com/en-us/library/windows/desktop/aa394399(v=vs.85).aspx