Looping thru task

J

Jeff

This code works in the VS2005 IDE using the built in web server,
however when I run it on the same machine thru IIS it throws an error
in the foreach loop. It's suppose to loop thru all the task in a
Microsoft Project file using C#.

object oAP = objProj.ActiveProject;
object prjTasks =
objProj.ActiveProject.GetType().InvokeMember("Tasks",

BindingFlags.DeclaredOnly |

BindingFlags.Public | BindingFlags.NonPublic |

BindingFlags.Instance | BindingFlags.InvokeMethod, null,oAP,null);

IEnumerable TaskList = (IEnumerable)prjTasks;
foreach (msPrj.Task prjTask in TaskList)
{
msPrj.Task myTask = (msPrj.Task)prjTask;
}

Here is the error:
Unable to cast COM object of type 'System.__ComObject' to interface
type 'Microsoft.Office.Interop.MSProject.Task'. This operation failed
because the QueryInterface call on the COM component for the interface
with IID '{000C0C3F-0000-0000-C000-000000000046}' failed due to the
following error: Error loading type library/DLL. (Exception from
HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).

Any help would be appreciated.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top