I'm having a strange issue related to talking to Microsoft.Office.Interop.MSProject. I'm using MSProject 2013 with Office.DLL v15 and Microsoft.Office.Interop.MSProject.DLL v15. We are updating our program, which sync's data between our product and project to use the latest DLLs, to support MSProject 2013. I'm going to attach images of code so you can see what I'm seeing.
I have a local variable that is assigned the value of the Project using the Interop class.
'Assembly Microsoft.Office.Interop.MSProject C:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office15\Microsoft.Office.Interop.MSProject.dll'
I'm looking for a value from Project.ProjectStart, which when I use the watch window shows a value.
BUT, when the code actually executes, the value of Project.ProjectStart = Null.
Things I've checked:
- Make sure that all projects build to x86 and that the Project I'm using is x86. However, I am on a 64bit Win7 machine. Could this be a x86 vs x64 dll issue?
This is a stumper. I'll buy you a Mountain Dew if you can help me out ;)
ANSWER FOUND!!!
This solution applies to all Microsoft.Office.Interop similar issues across all office apps.
Here is a thread I started on MSDN that found me my answer. http://social.msdn.microsoft.com/Forums/office/en-US/079ed850-b8ee-4d5f-93ad-a31f6d9c2607/microsoftofficeinteropmsproject-throwing-systemnotimplementedexception?forum=officegeneral#079ed850-b8ee-4d5f-93ad-a31f6d9c2607
Did you try to use the late binding technology (see Type.InvokeMember) for getting the value? Does it help? YES! is and answer. Type.InvokeMember works.
Here is a code snippet that I now use to access these members.
public DateTime LateBindProjectStart()
{
try
{
if (project != null)
{
if (project is Microsoft.Office.Interop.MSProject.Project)
{
DateTime dtStart = (DateTime)(typeof(Microsoft.Office.Interop.MSProject.Project).InvokeMember(
"ProjectStart",
BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public,
null,
project,
null));
return dtStart;
}
else
return DateTime.MinValue;
}
else
return DateTime.MinValue;
}
catch (Exception ex)
{
throw ex;
}
}