none
2015 Community Designer fails with NullReferenceException on all files

    Question

  • When I reopened my project (WPF C# Entity Framework 6, Windows 10), the designer reported an unhandled System.NullReferenceException on every one of my XAML files but one.  That one reports "System.InvalidOperationException - Sequence contains more than one element".  Of course, it was working fine when I shut it down, and I made no changes before seeing this problem. The project still opens fine in VS 2013.

    The computer is a Dell, not an HP.

    I have done everything I can think of, and followed all suggestions I can find, up to and including repairing and reinstalling VS 2015, and restoring the computer from an image backup from a week ago.  How can the problem possibly happen with a restored disk image???

    The trace for the InvalidOperationException starts with:

    System.InvalidOperationException
    Sequence contains more than one element
       at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineGenericParameters(Type type, MockTypeDefinition mockType)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.PopulateMockType(Type type, MockTypeDefinition mockType)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineType(Type type)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.MockGenericType(Type type)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineType(Type type)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineBaseType(Type baseType, MockTypeDefinition mockType)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.PopulateMockType(Type type, MockTypeDefinition mockType)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineType(Type type)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.MockType(Type type)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockType.InitializeMockType()
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockType.get_RuntimeType()
       at Microsoft.VisualStudio.DesignTools.Platform.Metadata.ProjectContextType.InitializeClass()
       at Microsoft.VisualStudio.DesignTools.Platform.Metadata.MemberCollection.get_PropertyIndex()... etc.

    and continues - after 100 or so more lines - with:

    System.InvalidOperationException
    Sequence contains more than one element
       at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.WaitForCompletion(NestedCallContext nestedCallContext, BlockingCall call, WaitHandle timeoutSignal)
       at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.STAMarshaler.MarshalOutSynchronous(Action action, Int32 targetApartmentId, WaitHandle aborted, WaitHandle timeoutSignal, CancellationToken cancelToken, String methodName, String filePath, Int32 lineNumber)
       at 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)
       at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.ThreadMarshaler.MarshalOut[TValue](RemoteHandle`1 targetObject, Action action, CancellationToken cancelToken, CallSynchronizationMode syncMode, ApartmentState apartmentState, String methodName, String filePath, Int32 lineNumber)
       at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.ThreadMarshaler.MarshalOut[TValue](RemoteHandle`1 targetObject, Action`1 action, CancellationToken cancelToken, CallSynchronizationMode syncMode, ApartmentState apartmentState, String methodName, String filePath, Int32 lineNumber)
       at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.LocalDesignerService.MarshalOutWithCancellation[TResult](CancellationToken cancelToken, Func`3 func, ApartmentState apartmentState)
       at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Remoting.LocalDesignerService.Microsoft.VisualStudio.DesignTools.DesignerContract.IDesignerService.CreateDesigner(IHostSourceItem item, IHostTextEditor editor, CancellationToken cancelToken)
       at Microsoft.VisualStudio.DesignTools.DesignerContract.IsolatedDesignerService.IsolatedDesignerView.CreateDesignerViewInfo(CancellationToken cancelToken)

    The NullReferenceException error looks like:

    System.NullReferenceException
    Object reference not set to an instance of an object.
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeDefinition.DefineVirtualMethod(MethodDefinition method, Boolean shouldOverride, Nullable`1 additionalAttributes)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineBaseType(Type baseType, MockTypeDefinition mockType)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.PopulateMockType(Type type, MockTypeDefinition mockType)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineType(Type type)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineBaseType(Type baseType, MockTypeDefinition mockType)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.PopulateMockType(Type type, MockTypeDefinition mockType)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineType(Type type)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineProperty(TypeDefinition typeDefinition, PropertyInfo propertyInfo)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineInterfaces(MockTypeDefinition mockType, Type type)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.PopulateMockType(Type type, MockTypeDefinition mockType)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineType(Type type)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineBaseType(Type baseType, MockTypeDefinition mockType)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.PopulateMockType(Type type, MockTypeDefinition mockType)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineType(Type type)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineProperty(TypeDefinition typeDefinition, PropertyInfo propertyInfo)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.PopulateMockType(Type type, MockTypeDefinition mockType)
       at Microsoft.VisualStudio.DesignTools.XamlDesigner.Metadata.MockTypes.MockTypeGenerator.DefineType(Type type)...

    Followed by several hundred more lines.  I will be happy to supply the rest of the trace(s) if it will do any good.

    I hope you can suggest a fix for this, because I am dead in the water until there is one.

    Thanks.

    Sunday, November 29, 2015 10:05 PM

Answers

  • Hi Clark,

    Since you had opened the project on your main development machine and got the same error. I think the error is probably caused by your WPF project.

    >>I have created a new, clean project and am in the process of copying the contents of all 80+ files into the new project, but this is going to take a while.  I'll let you know how it goes.

    If you have any update, please feel free to share the results here.

    Best Regards,

    Lake Xiao


    Thursday, December 3, 2015 8:53 AM
    Moderator

All replies

  • Hi cdgodfrey,

    Thanks for your post.

    I tried to reproduce the issue but to no avail.

    I suggest you could create a sample WPF project and check if the issue will reproduce.

    1. If the designer loaded fine for the sample WPF. I suspect if something was wrong with your WPF project.

    Since the project opens fine in VS2013. Could you tell me where the WPF project was created, in VS2013 or in VS 2015?

    If the project was created in VS2013. I suggest you could create a new WPF project in VS2015 Community and copy your code from XAML file in your WPF project to the new WPF project.

    2. If still give same error for the new WPF project. I doubt the problem might be your VS in your environment.

    In this case, I suggest you could change another machine using same VS version and test it again.

    If it works fine on another machine using same VS. I think there may be some problem when you installing your VS.

    Since you had tried repaired and reinstalled.

    I suggest you could repair your VS again and use the collect.exe tool to collect the installation logs and upload the vslogs.cab file the %temp% folder to the OneDrive then send me the link, I will take a look at it for you.



    Best Regards,

    Lake Xiao
    Wednesday, December 2, 2015 5:17 AM
    Moderator
  • Thanks for digging into thei - I'm not surprised that you weren't able to reproduce the problem, though.

    The problem occurred on my portable computer while I was working away from home.  When I got back, I opened the project on my main development machine, and had the same issue.  Except that now it crashes VS 2013, too.  

    I have created a new, clean project and am in the process of copying the contents of all 80+ files into the new project, but this is going to take a while.  I'll let you know how it goes.

    Thanks again for responding!

    Clark

    Wednesday, December 2, 2015 10:26 PM
  • Hi Clark,

    Since you had opened the project on your main development machine and got the same error. I think the error is probably caused by your WPF project.

    >>I have created a new, clean project and am in the process of copying the contents of all 80+ files into the new project, but this is going to take a while.  I'll let you know how it goes.

    If you have any update, please feel free to share the results here.

    Best Regards,

    Lake Xiao


    Thursday, December 3, 2015 8:53 AM
    Moderator
  • I have had to suspend work on this while I am travelling, but before I left I did get some of the program copied into another project - enough of the program to start trying pieces of it - and so far it is working.  If at some point it stops working, at least I will have a clue where to look.

    Thanks for your help,

    Clark

    Tuesday, December 8, 2015 3:15 AM