Howdy,
Real head scratcher on this one. I have a full description of the problem with screen shots at Stackoverflow: http://stackoverflow.com/questions/25043560/microsoft-office-interop-msproject-giving-null-at-runtime-but-has-value-in-visu
The crux of the issue:
I'm opening a MSProject File in a WPF C# Program utilizing interop. I attempt to read the Project.ProjectFinish and Project.ProjectStart properties and get a System.NotImplementedException. However, if I look at these values in the debugger->watch window, I can see their values fine.
Why would my runtime code not see the value from the interop class, but the debugger would?
Based on a few things I've read on the interweb and on this forum, I've added this code:
if (dynProject is Microsoft.Office.Interop.MSProject.Project) { DateTime dtFinish = dynProject.ProjectFinish; }
If statement is true, but
DateTime dtFinish = dynProject.ProjectFinish;
throws the System.NotImplementedException. And, if I look at that value in the debugger, the value is there.
Context Info
- WPF C# .NET 4.0 Program
- Visual Studio 2010
- MSProject 2013
- Microsoft.Office.Interop.MSProject v15 referenced from C:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office15\Microsoft.Office.Interop.MSProject.dll
- Microsoft.Office.Interop.Office v15 referenced from C:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office15\Office.dll
Full Stack Track of the Exception:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode) at System.Dynamic.ComRuntimeHelpers.GetITypeInfoFromIDispatch(IDispatch dispatch, Boolean throwIfMissingExpectedTypeInfo) at System.Dynamic.IDispatchComObject.EnsureScanDefinedMethods() at System.Dynamic.IDispatchComObject.System.Dynamic.IDynamicMetaObjectProvider.GetMetaObject(Expression parameter) at System.Dynamic.DynamicMetaObject.Create(Object value, Expression expression) at System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, ReadOnlyCollection`1 parameters, LabelTarget returnLabel) at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite`1 site, Object[] args) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)