none
XAML designer in new WPF project throws System.Argument.Exception upfront in new solution RRS feed

  • Question

  • Hi,

    I am using Visual Studio 2015 Community Edition. I worked with a few WPF projects. The projects themselves still compile and run in VS, it is just the XAML Designer that suddenly does not work any longer.

    This does not seem to be related to the projects, as I first thought.

    When I create a NEW WPF project in the "New Project" C# dialog window, the XAML Designer brings an exception upfront, as shown below.

    A "repair" for VS 2015 from control panel, programs and features, which took at least 90 minutes, did not help.

    After googling the exception I realized this occurs often. Yet nowhere did I find a solution. It goes like this:

    An Unhandled Exception has occurred.                                             

    Click here to reload the designer (which does not remedy anything).

    Details

    System.ArgumentException

    An item with the same key has already been added.

       at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)   at Microsoft.VisualStudio.DesignTools.Utility.Telemetry.VsTelemetryService.RegisterDesignerProcessSession(Int32 pid)   at Microsoft.VisualStudio.DesignTools.Utility.Feedback.WatsonTracker.RegisterSession(Int32 processID)   at Microsoft.VisualStudio.DesignTools.Utility.DesignerSessionTracker.RecordDesignerStart(Int32 processID, String isolationTargetIdentifier, Boolean mockCustomTypes, String buildConfiguration)   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.ProcessDomainFactory.ProcessIsolationDomain..ctor(ProcessDomainFactory factory, IIsolationBoundary boundary, AppDomainSetup appDomainInfo, IIsolationTarget isolationTarget, String baseDirectory)   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.ProcessDomainFactory.CreateIsolationDomain(IIsolationBoundary boundary)   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.IsolationBoundary.Initialize()   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.Primitives.IsolationBoundary.CreateInstance[T](Type type)   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolatedObjectFactory.Initialize()   at Microsoft.VisualStudio.DesignTools.DesignerHost.Services.VSIsolationService.CreateObjectFactory(IIsolationTarget isolationTarget, IObjectCatalog catalog)   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolationService.CreateLease(IIsolationTarget isolationTarget)   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolationService.CreateLease(IIsolationTarget isolationTarget)   at Microsoft.VisualStudio.DesignTools.DesignerContract.IsolatedDesignerService.CreateLease(IIsolationTarget isolationTarget, CancellationToken cancelToken, DesignerServiceEntry& entry, IServiceProvider serviceOverrides)   at Microsoft.VisualStudio.DesignTools.DesignerContract.IsolatedDesignerService.IsolatedDesignerView.CreateDesignerViewInfo(CancellationToken cancelToken)   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolatedTaskScheduler.InvokeWithCulture[T](CultureInfo culture, Func`2 func, CancellationToken cancelToken)   at Microsoft.VisualStudio.DesignTools.DesignerContract.Isolation.IsolatedTaskScheduler.<>c__DisplayClass10_0`1.<StartTask>b__0()   at System.Threading.Tasks.Task`1.InnerInvoke()   at System.Threading.Tasks.Task.Execute()


    How can this be in a newly created WPF project within a virgin solution?

    As this is a specialized forum on Windows Presentation Foundation, perhaps s.b. here knows?

    Actually, Microsoft should be interested in a solution themselves, as this should not occur after starting a new WPF project in a new solution.

    Thx for any hints.



    Andreas





    • Edited by AndiMzD Tuesday, December 1, 2015 1:17 PM
    Tuesday, December 1, 2015 1:00 PM

Answers

  • Since this is probably not anything that will happen to all users that install the community edition of Visual Studio 2015 and create a new WPF project, it is probably something on your machine that is causing this behvaiour. I think the best thing you can do if you don't manage to solve it is to reinstall Visual Studio.

    If you need more help regarding Visual Studio related issues, I suggest you ask in the VS forums for better help: https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=visualstudiogeneral

    I doubt that you will find anyone that will be able to reproduce your exact same issue without having access to your computer though so the fastest way to solve this is probably to reinstall VS.

    If you believe that you have found a bug, you should report it at Connect: https://connect.microsoft.com/. Please remember to include all necassary details for the engineers at Microsoft to be able to reproduce the issue if you do decide to file a bug report.

    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    Wednesday, December 2, 2015 3:44 PM

All replies

  • Hi,

    I took the projects home on a stick and ran them in another installation of VS 2015 - no problem. The XAML Designer was running ok.

    So the installation of VS 2015 at work is messed up.

    Ideally I would just come to know what the problem is and adjust VS in just the right place - and get the WPF XAML designer working again. 

    I am afraid, I have to uninstall VS completely and install it again...
    Or would someone have an idea what I could do?

    Would be nice to know a solution to this one.

    Thx


    Andreas


    • Edited by AndiMzD Wednesday, December 2, 2015 9:32 AM
    Wednesday, December 2, 2015 9:27 AM
  • I read this last night.

    I think an uninstall will be necessary.

    You have some template or settings somewhere messed up.

    The refresh doesn't redo such stuff.

    You could try forcing a reset on the settings and templates.

    Tools > Import and Export Settings > Reset all settings

    and from a vs cmd prompt

    devenv /installvstemplates

    If you're really lucky it's a project template is broken.

    Cross your fingers, get out the lucky rabbit's paw and 4 leaf clover... etc.

    Good luck!

    .

    As something of an aside.

    VS seems much more stable nowadays than it used to be. I rarely have to re-install nowadays and it used to be every 4-6 months. Some places run vs on a virtual machine so they can just re-set to default easy.  With the power of modern desktops and improvements in virtual machine technology, it's something I've had on my list to try.


    Hope that helps.

    Technet articles: WPF: Layout Lab; All my Technet Articles


    Wednesday, December 2, 2015 9:48 AM
    Moderator
  • Since this is probably not anything that will happen to all users that install the community edition of Visual Studio 2015 and create a new WPF project, it is probably something on your machine that is causing this behvaiour. I think the best thing you can do if you don't manage to solve it is to reinstall Visual Studio.

    If you need more help regarding Visual Studio related issues, I suggest you ask in the VS forums for better help: https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=visualstudiogeneral

    I doubt that you will find anyone that will be able to reproduce your exact same issue without having access to your computer though so the fastest way to solve this is probably to reinstall VS.

    If you believe that you have found a bug, you should report it at Connect: https://connect.microsoft.com/. Please remember to include all necassary details for the engineers at Microsoft to be able to reproduce the issue if you do decide to file a bug report.

    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    Wednesday, December 2, 2015 3:44 PM
  • Both did not remedy anything. Will re-install now. 

    I am not aware having done anything out of the ordinary.

    Hopefully a re-install will do the trick.

    Regards,


    Andreas

    Wednesday, December 2, 2015 4:13 PM
  • Visual Studio is perfectly capable of corrupting itself in weird ways without a developer helping it do so.

    It happens less often nowadays but it still happens.


    Hope that helps.

    Technet articles: WPF: Layout Lab; All my Technet Articles

    Wednesday, December 2, 2015 4:22 PM
    Moderator
  • Did the re-install work for you? I'm suddenly running into the same error with an install of VS Pro 2015 Update 1.
    Wednesday, December 16, 2015 4:42 PM
  • I think your problem is related to one or more of the dll listed here:

    https://msdn.microsoft.com/en-gb/library/bb514646%28v=vs.90%29.aspx?f=255&MSPPError=-2147217396

    For some reason one of them is being loaded more than once.

    That collision gives the error which is rather reminiscent of a dictionary collision.

    If you search on "Microsoft.windows.design.* on your c drive you'll find a LOAD of files qualify. They're all over the place. In the gac, shadow caches.... stacks of the things.

    Proving my thinking is going to be tricky but you could take that route.

    I think it'd probably be easier to uninstall and re-install though.

    .

    I guess this issue might break blend as well.

    BUT

    Open blend and see if your designer works in that. If it doesn't then you're done and re-install.

    If it works then you have the option of a short term work round.

    Turn off the visual studio xaml designer entirely.

    In visual studio.

    Tools > Options

    Search XAML

    Choose XAML designer.

    Uncheck the box at the top which says "Enable XAML designer".

    Re-start and your xaml designer is no more.

    You could try setting it back to on and restarting.

    I don't hold out much hope but you never know.

    I met someone who prefers working with blend and visual studio in this way.

    Maybe it'll grow on you.

    If it works for you then please post back in this thread.

    Bit tricky to test this one without a problem.


    Hope that helps.

    Technet articles: WPF: Layout Lab; All my Technet Articles

    Wednesday, December 16, 2015 6:59 PM
    Moderator
  • For what it's worth I did a full re-install of VS 2015 and that didn't solve the issue. Is a complete format the only way people have worked around this problem??

    I've seen several cases of people posting about this on stackoverflow, but no one has seemed to find a good resolution so I'm a little lost on how even to debug this further. 

    Monday, May 23, 2016 1:05 PM
  • I had the issue and it is easy to reproduce. Please have a look at this http://stackoverflow.com/questions/34366595/an-item-with-the-same-key-has-already-been-added-when-creating-new-wpf-project. If the computer with the designer not working has a file "C:\Program", try to delete or rename it then click on "Click here to reload the designer" in Visual Studio. I renamed mine Program_1 and it fixed the issue.
    Thursday, February 9, 2017 4:34 AM