【问题标题】:Visual studio Windows Form designer error: "Construction of frame content failed."Visual Studio Windows 窗体设计器错误:“构建框架内容失败。”
【发布时间】:2018-10-15 08:34:43
【问题描述】:

在我将UserControl 添加到我的Form 后,它突然开始产生此错误:

对 COM 组件的调用已返回错误 HRESULT E_FAIL

所以我搜索了一下,发现它与缓存有某种关系。所以我从我的解决方案中删除了suo 文件。现在它产生了这个错误:

未指定的错误(HRESULT 异常:0x80004005 (E_FAIL))

我也用谷歌搜索过,发现我应该阅读ActivityLog.xml 的内容,可以在%appdata%\Microsoft\VisualStudio 中找到。它以这条消息开头:

框架内容构造失败。

我找不到任何进一步的解决方案。

这是该日志中的完整错误:

帧内容构造失败。帧标识符: ST:0:0:{31fc2115-5126-4a87-b2f7-77eaab65048b} 帧标题:异常 详细信息:System.ArgumentNullException:参数名称:protocolHandler 在 Microsoft.XamlDiagnostics.UI.LivePropertyExplorer.Model.PropertyExplorerModel..ctor(IProtocolHandler protocolHandler, IActiveElementTracker 跟踪器, ITelemetryLogger 遥测记录器)在 Microsoft.XamlDiagnostics.Model.XamlDiagnosticsTool.GetPropertyExplorerModel(IServiceProvider 服务提供商)在 Microsoft.XamlDiagnostics.Model.XamlDiagnosticsTool.CreatePropertyExplorer(IServiceProvider serviceProvider, ResourceDictionary 主题字典, UIElement 搜索内容控制)在 Microsoft.VisualStudio.ClientDiagnostics.XamlDiagnostics.PropertyExplorerToolWindow.GetContent() 在 Microsoft.VisualStudio.ClientDiagnostics.XamlDiagnostics.XamlDiagnosticsToolWindowBase.ShowContent() 在 Microsoft.VisualStudio.ClientDiagnostics.XamlDiagnostics.XamlDiagnosticsToolWindowBase.Initialize() 在 Microsoft.VisualStudio.Shell.WindowPane.InternalSetSite(IServiceProvider p) 在 Microsoft.VisualStudio.Shell.WindowPane.Microsoft.VisualStudio.Shell.Interop.IVsWindowPane.SetSite(IServiceProvider psp)在 Microsoft.VisualStudio.Shell.WindowPane.Microsoft.VisualStudio.Shell.Interop.IVsUIElementPane.SetUIElementSite(IServiceProvider p) 在 Microsoft.VisualStudio.Platform.WindowManagement.UIElementDocumentObject.SetSite(DocumentObjectSite 网站)在 Microsoft.VisualStudio.Platform.WindowManagement.DocumentObjectSite.InitializeDocumentObject(对象 punkView)在 Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.CreateContentPane(FrameMoniker frameMoniker,布尔 isDocument,字符串 lpstrMkDoc,UInt32 eCreateWindowFlags、对象 punkView、对象 punkData、IServiceProvider pServiceProvider, IVsUIHierarchy pUIHierarchy, UInt32 vsid, Guid rguidCmdUI, ViewGroup parent, IVsWindowFrame& ppWindowFrame) 在 Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.CreateContentPane(字符串 pszName,Int32 fDockViewOn,Int32 fDocument,字符串 lpstrMkDoc,UInt32 eCreateWindowFlags,UInt32 dwToolWinId,对象 punkView,对象 punkData、IServiceProvider pServiceProvider、IVsUIHierarchy pUIHierarchy, UInt32 vsid, Int32& pfDefaultPosition, Guid& rguidCmdUI, IVsWindowFrame& ppWindowFrame) 在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 错误代码,IntPtr 错误信息)在 Microsoft.VisualStudio.Shell.Package.CreateToolWindow(类型 toolWindowType、Int32 id、UInt32 标志)在 Microsoft.VisualStudio.Shell.Package.CreateToolWindow(类型 toolWindowType、Int32 id、ProvideToolWindowAttribute 工具)在 Microsoft.VisualStudio.Shell.Package.FindToolWindow(类型 toolWindowType, Int32 id, Boolean create, ProvideToolWindowAttribute 工具)在 Microsoft.VisualStudio.Shell.Package.CreateToolWindow(Guid& toolWindowType, Int32 id) 在 Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsToolWindowFactory.CreateToolWindow(Guid& toolWindowType, UInt32 id) 在 Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.ConstructContent()

发生了什么事? Construction of frame content failed 是什么意思?

【问题讨论】:

  • 可能设计者正在尝试绘制您的用户控件的渲染并且在执行此操作时遇到错误(来自您的控件)
  • @CaiusJard 你说得对,我刚刚注意到一个警告说用户控件和完全相同的用户控件之间存在冲突

标签: c# visual-studio windows-forms-designer


【解决方案1】:

感谢 Caius,我设法找到了问题所在。由于UserControl 出现错误,设计器无法渲染Form。我查看了 Designer.cs 文件,发现一条警告说 [path] 中的 UserControl [version] 和 [path] 中的 UserControl 之间存在冲突。

我查看了该项目的引用,并在那里找到了一个自我引用!所以我删除了它,错误就消失了。

UserControlForm 在同一个项目中,在将UserControl 添加到Form 时,我将UserControlToolbox 拖放到Form 上。所以它自动为我的项目添加了一个自引用。我不确定它为什么这样做。但是删除引用解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-07
    • 1970-01-01
    • 1970-01-01
    • 2015-09-28
    相关资源
    最近更新 更多