创建新的WPF项目时,已经添加了具有相同键的项目 [英] An item with the same key has already been added when creating new WPF project

查看:115
本文介绍了创建新的WPF项目时,已经添加了具有相同键的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在Visual Studio 2015 Pro中创建了一个新的WPF
项目,并且在创建项目对话框消失后,我没有看到设计器。这个ArgumentException只是显示在那里,我没有添加任何控件或任何东西。

I just created a new WPF project in Visual Studio 2015 Pro, and after the Creating Project dialog disappears, I do not get the designer. This ArgumentException just shows there and I have not added any controls or anything. Just created the project and I get this.

我已经阅读了当我有重复的文件(例如带有Resources.resx名称的resx文件或我喜欢的LIKE文件)时抛出的异常使用两次相同的文件,但除了创建新项目外,我什么也没做。

I have read this exception is thrown when I have duplicate files like a resx file with Resources.resx name or LIKE when I am using the same file twice but I am not doing anything else than creating a new project.

我可以成功构建解决方案,并且项目没有错误。我打开已编译的EXE,看起来不错。但是我不能在VS内部使用设计器。

I can build the solution and the project successfully with no errors. I open the compiled EXE and it looks OK. But I cannot use the designer inside VS.

此WPF解决方案面向.NET4.5。我尝试创建一个针对其他.NET版本的新对象,但同样如此。

This WPF solution targets .NET4.5. I tried creating a new one targetting other .NET versions but the same happens.


这是VS抛出的整个异常:

Here is the entire exception thrown by VS:

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.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()

以下也是屏幕截图:< a href = https://i.stack.imgur.com/SM2ht.png rel = noreferrer>

希望有人可以帮助我解决此问题。在此先感谢-CCB

Hope someone can help me solve this problem. Thanks in Advance - CCB

推荐答案

我遇到了同样的异常,并且在没有任何帮助的情况下将xaml和cs减少到最小。我删除了bin和obj文件夹,重新启动了VS,重新启动了我的计算机,但是仍然没有运气。在VS 2012中,设计人员未加载其他错误消息。这篇帖子帮助我解决了该问题

I got the same exception and reduced both xaml and cs to a minimum without any help. I deleted folders bin and obj, restarted VS, rebooted my computer, but still no luck. With VS 2012 the designer was not loading with a different error message. This post helped me fix the issue

修复:删除或重命名文件 C:\Program,然后单击单击此处重新加载设计器。

在我的情况下,Program是一个文本文件,没有写入ipconfig MS-DOS命令的输出的扩展名。无需关闭xaml设计器,重新编译,清除缓存或重新启动Visual Studio。

In my case Program was a text file without extension from writing the output of an ipconfig MS-DOS command. There is no need to close the xaml designer, recompile, clear the cache, or restart Visual Studio.

在加载设计器时VS尝试读取它(已通过Process检查)从Sysinternals监视)。有关信息,Visual Studio 2012中的堆栈与此错误报告

Somehow VS tries to read it when loading the designer (checked with Process Monitor from Sysinternals). For information the stack in Visual Studio 2012 was the same as this bug report.

System.Runtime.Remoting.RemotingException
[] Designer process terminated unexpectedly!
   at Microsoft.Expression.DesignHost.Isolation.Primitives.ProcessDomainFactory.ProcessIsolationDomain.Microsoft.Expression.DesignHost.Isolation.IIsolationDomain.CreateInstance(String assemblyName, String assemblyCodeBase, String typeName)
   at Microsoft.Expression.DesignHost.Isolation.Primitives.IsolationBoundary.Initialize()
   at Microsoft.Expression.DesignHost.Isolation.Primitives.IsolationBoundary.CreateInstance[T](Type type)
   at Microsoft.Expression.DesignHost.Isolation.IsolatedExportProvider.Initialize()
   at Microsoft.VisualStudio.ExpressionHost.Services.VSIsolationService.CreateExportProvider(IIsolationTarget isolationTarget, ICatalogFactory catalogFactory, IExportFilter filter)
   at Microsoft.Expression.DesignHost.Isolation.IsolationService.CreateLease(IIsolationTarget isolationTarget)
   at Microsoft.Expression.DesignHost.IsolatedDesignerService.CreateLease(IIsolationTarget isolationTarget, CancellationToken cancelToken, DesignerServiceEntry& entry)
   at Microsoft.Expression.DesignHost.IsolatedDesignerService.IsolatedDesignerView.CreateDesignerViewInfo(CancellationToken cancelToken)
   at Microsoft.Expression.DesignHost.Isolation.IsolatedTaskScheduler.InvokeWithCulture[T](CultureInfo culture, Func`2 func, CancellationToken cancelToken)
   at Microsoft.Expression.DesignHost.Isolation.IsolatedTaskScheduler.<>c__DisplayClassa`1.<StartTask>b__6()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

这篇关于创建新的WPF项目时,已经添加了具有相同键的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆