none
WPF designer Crashes with null reference exception

    Question

  • It seems that WPF have some problems to find resources in a larger WPF Components. It happens from time to time with the same Componets . 

    it is some thing like:

      
     bei Microsoft.VisualStudio.DesignTools.DesignerHost.VSUtilities.GetBuildAction(IVsHierarchy hierarchy, UInt32 itemId)
       bei Microsoft.VisualStudio.DesignTools.DesignerHost.HostServices.HostSourceItem.<>c__DisplayClass44_0.<get_BuildItemType>b__0()
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.Call.InvokeWorker()
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.Call.Invoke(Boolean waitingInExternalCall)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.InvokeCall(Call call)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.DirectInvoke(Boolean inbound, Action action, Int32 sourceApartmentId, Int32 targetApartmentId, Int32 originId, WaitHandle aborted)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.DirectInvokeInbound(Action action, Int32 targetApartmentId)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.MarshalIn(Action action, Int32 targetApartmentId, CancellationToken cancelToken, CallSynchronizationMode syncMode, CallModality callModality, String methodName,
     String filePath, Int32 lineNumber)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.ThreadMarshaler.MarshalIn(IRemoteObject targetObject, Action action, CallSynchronizationMode syncMode, CallModality callModality, ApartmentState apartmentState, String memberName,
     String filePath, Int32 lineNumber)
       bei Microsoft.VisualStudio.DesignTools.DesignerHost.HostServices.HostSourceItem.get_BuildItemType()
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.HostSourceItemData..ctor(IHostSourceItem item)
       bei Microsoft.VisualStudio.DesignTools.DesignerHost.HostServices.HostSourceItem.get_ItemData()
       bei Microsoft.VisualStudio.DesignTools.DesignerHost.HostServices.HostProject.<>c.<get_InitializationData>b__343_0(HostSourceItem item)
       bei System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       bei System.Linq.Buffer`1..ctor(IEnumerable`1 source)
       bei System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
       bei Microsoft.VisualStudio.DesignTools.DesignerHost.HostServices.HostProject.get_InitializationData()
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.RemoteHostProject.<Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.IRemoteHostProject.get_InitializationData>b__101_0()
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.ThreadMarshaler.<>c__DisplayClass47_0`1.<MarshalIn>b__0()
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.Call.InvokeWorker()
    
    System.NullReferenceException
    Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
    
    Server stack trace: 
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext, BlockingCall call, WaitHandle timeoutSignal)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.MarshalInSynchronous(Action action, Int32 targetApartmentId, CancellationToken cancelToken, CallModality callModality, String methodName, String filePath, Int32
     lineNumber)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.MarshalIn(Action action, Int32 targetApartmentId, CancellationToken cancelToken, CallSynchronizationMode syncMode, CallModality callModality, String methodName,
     String filePath, Int32 lineNumber)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.ThreadMarshaler.MarshalIn(IRemoteObject targetObject, Action action, CallSynchronizationMode syncMode, CallModality callModality, ApartmentState apartmentState, String memberName,
     String filePath, Int32 lineNumber)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.ThreadMarshaler.MarshalIn[TResult](IRemoteObject targetObject, Func`1 func, CallModality callModality, ApartmentState apartmentState, String memberName, String filePath,
     Int32 lineNumber)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.RemoteHostProject.Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.IRemoteHostProject.get_InitializationData()
       bei System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
       bei System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
    
    Exception rethrown at [0]: 
       bei System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       bei System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.IRemoteHostProject.get_InitializationData()
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.LocalHostProject.<>c.<Microsoft.VisualStudio.DesignTools.DesignerContract.IHostProject.get_InitializationData>b__122_0(IRemoteHostProject p)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.ThreadMarshaler.<>c__DisplayClass31_0`2.<MarshalOut>b__0()
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.Call.InvokeWorker()
    
    System.NullReferenceException
    Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext, BlockingCall call, WaitHandle timeoutSignal)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.MarshalOutSynchronous(Action action, Int32 targetApartmentId, WaitHandle aborted, WaitHandle timeoutSignal, CancellationToken cancelToken, String methodName,
     String filePath, Int32 lineNumber)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.MarshalOut(Action action, Int32 targetApartmentId, WaitHandle aborted, CancellationToken cancelToken, CallSynchronizationMode syncMode, WaitHandle timeoutSignal,
     String methodName, String filePath, Int32 lineNumber)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.ThreadMarshaler.MarshalOut[TValue](RemoteHandle`1 targetObject, Action action, CallSynchronizationMode syncMode, ApartmentState apartmentState, String methodName, String
     filePath, Int32 lineNumber)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.ThreadMarshaler.MarshalOut[TResult,TValue](RemoteHandle`1 targetObject, Func`2 func, CallSynchronizationMode syncMode, ApartmentState apartmentState, String methodName,
     String filePath, Int32 lineNumber)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.LocalHostProject.Microsoft.VisualStudio.DesignTools.DesignerContract.IHostProject.get_InitializationData()
       bei Microsoft.VisualStudio.DesignTools.Designer.Project.ProjectContextBase.InitializeProject()
       bei Microsoft.VisualStudio.DesignTools.XamlDesigner.DocumentModel.XamlProjectContext.InitializeProject()
       bei Microsoft.VisualStudio.DesignTools.Designer.Project.ProjectContextBase.Initialize(IHostProject project, Action cancelCallback)
       bei Microsoft.VisualStudio.DesignTools.Designer.Project.ProjectContextManager.GetProjectContext(IHostProject project, IPlatform platform, Boolean create)
       bei Microsoft.VisualStudio.DesignTools.Designer.Project.ProjectContextManager.<GetContextsInActiveSolution>d__101.MoveNext()
       bei Microsoft.VisualStudio.DesignTools.XamlDesigner.Commands.ReplaceStyleTemplateCommand.ResolveDefaultStyle(SceneNode targetElement, Object defaultStyleKey, Boolean allowDefaultStyle, DocumentNode& currentStyle, Boolean& isThemeStyle,
     IList`1& auxiliaryResources)
       bei Microsoft.VisualStudio.DesignTools.XamlDesigner.Commands.ReplaceStyleTemplateCommand.ProvideCurrentStyle(SceneNode targetElement, IType targetType, PropertyReference targetPropertyReference, Boolean allowDefaultStyle, IList`1& auxiliaryResources)
       bei Microsoft.VisualStudio.DesignTools.XamlDesigner.Commands.EditCopyOfStyleCommand.get_IsEnabled()
       bei Microsoft.VisualStudio.DesignTools.Utility.Commands.Command.GetProperty(String propertyName, Object defaultValue)
       bei Microsoft.VisualStudio.DesignTools.XamlDesigner.Commands.ReplaceStyleTemplateCommand.GetProperty(String propertyName)
       bei Microsoft.VisualStudio.DesignTools.Designer.View.SceneView.UpdateCommandState(IEnumerable`1 commandNames, Boolean forceRefresh)
       bei Microsoft.VisualStudio.DesignTools.Designer.View.SceneView.SelectionManager_LateActiveSceneUpdatePhase(Object sender, SceneUpdatePhaseEventArgs args)
       bei Microsoft.VisualStudio.DesignTools.Designer.ViewModel.SceneUpdatePhaseEventHandler.Invoke(Object sender, SceneUpdatePhaseEventArgs e)
       bei Microsoft.VisualStudio.DesignTools.Designer.Selection.SelectionManager.FireLateActiveSceneUpdatePhase(SceneUpdatePhaseEventArgs args)
       bei Microsoft.VisualStudio.DesignTools.Designer.View.SceneViewUpdateScheduleTask.UpdateLate()
       bei Microsoft.VisualStudio.DesignTools.Utility.Scheduler.ScheduleTask.Update()
       bei Microsoft.VisualStudio.DesignTools.Utility.Scheduler.SchedulingService.DispatchTasksAtPriority(DispatcherPriority priority)
       bei Microsoft.VisualStudio.DesignTools.Utility.Scheduler.SchedulingService.DispatcherToken.Dispatch(Object arg)
       bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       bei System.Windows.Threading.DispatcherOperation.InvokeImpl()
       bei System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       bei MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
       bei System.Windows.Threading.DispatcherOperation.Invoke()
       bei System.Windows.Threading.Dispatcher.ProcessQueue()
       bei System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       bei MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       bei System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       bei System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       bei System.Windows.Application.RunDispatcher(Object ignore)
       bei System.Windows.Application.RunInternal(Window window)
       bei System.Windows.Application.Run(Window window)
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.DesignerProcess.RunApplication()
       bei Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.DesignerProcess.<>c__DisplayClass5_0.<Main>b__0()
       bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       bei System.Threading.ThreadHelper.ThreadStart()



    The Components are in different assemblies and  uses ResourcesDicttionaries and resources created by Resx Manager.

    Some times  Says xaml Editor that thise o those name space is not found. How ever i have not any problem to build and run my application. The issue is only due design time. Does anybody work around?



    Tuesday, March 15, 2016 9:14 AM

Answers

  • Hi Alexander Gornosatev,

    To really repro this issue, could you share us a simple sample using one drive? So we could really make sure that whether it is related to the VS IDE, the project itself or others.

    If you create a blank WPF app, whether the designer works well?

    If all WPF apps have the same issue, reset your VS settings, and then re-create a new project, check it again. Or you could repair your VS if still no help.

    Maybe you could open it in other VS machine, so we could know that whether it is related to your VS.

    But if just the specific app has the same issue in other machine, I think it would be related to the project itself.

    (1)Close the designer, and re-open it again.

    (2)Delete .suo file in your project folder, and then re-open the .xxproj file, clean and rebuild your app, open the designer file again.

    (3) Create a blank solution, and then add all project files to this new blank solution, test it again.

    If still no help, just a workaround is that maybe you could comment out certain code lines, so we could know that whether it is related to the specific code line.

    Best Regards,

    Jack 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 22, 2016 12:24 PM
    Moderator

All replies

  • Hi Alexander Gornosatev,

    Move to Visual Studio General forum for a better support, thanks for your understanding :)

    Best Regards,

    Xavier Eoro


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 18, 2016 4:56 AM
  • Hi Alexander Gornosatev,

    To really repro this issue, could you share us a simple sample using one drive? So we could really make sure that whether it is related to the VS IDE, the project itself or others.

    If you create a blank WPF app, whether the designer works well?

    If all WPF apps have the same issue, reset your VS settings, and then re-create a new project, check it again. Or you could repair your VS if still no help.

    Maybe you could open it in other VS machine, so we could know that whether it is related to your VS.

    But if just the specific app has the same issue in other machine, I think it would be related to the project itself.

    (1)Close the designer, and re-open it again.

    (2)Delete .suo file in your project folder, and then re-open the .xxproj file, clean and rebuild your app, open the designer file again.

    (3) Create a blank solution, and then add all project files to this new blank solution, test it again.

    If still no help, just a workaround is that maybe you could comment out certain code lines, so we could know that whether it is related to the specific code line.

    Best Regards,

    Jack 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 22, 2016 12:24 PM
    Moderator