visual studio表单设计器:创建新表单时出错

时间:2012-04-10 13:57:25

标签: visual-studio

我正在使用C#中的visualstudio10开发一个项目。 在我创建了一个表单后,我尝试在项目中添加另一个表单,但VS无法打开设计器,也无法为表单创建正确的文件 它只创建一个名为“form2.cs”的文件和另一个名为“form2.designer.cs”的文件,但它不会打开设计器。相反,它会响应以下消息: “创建'命名空间提供程序'时出错”并向我显示调用堆栈如下:

in Microsoft.VisualStudio.CSharp.Services.Language.Interop.IWorld.ConstructNamespace(IntPtr owner, IntPtr baseNodePtr, Boolean noTypeRestrictionInNamespace)
in Microsoft.VisualStudio.CSharp.Services.Language.Interop.WorldExtensions.ConstructNamespaceFromNode(IWorld world, ParseTreeNode context, Boolean noTypeRestriction)
in Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CFileCodeModel.TryBindType(Compilation compilation, TypeBaseNode typeNode)
in Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CBasesCollection.IsBaseDefined(Compilation compilation, ParseTreeNode pNode)
in Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CBasesCollection.Item(Object vtIndex)
in Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CSlowSnapshot..ctor(CodeElements collection)
in Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CBasesCollection.CreateSnapshot()
in Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CCollectionBase.GetEnumerator()
in EnvDTE.CodeElements.GetEnumerator()
in Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.CodeTypeDeclarationFromCodeClass(CodeClass vsClass)
in Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.OnNamespacePopulateTypes(Object sender, EventArgs e)
in System.CodeDom.CodeNamespace.get_Types()  
in Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.Parse(TextReader codeStream)
in Microsoft.VisualStudio.Design.Serialization.CodeDom.MergedCodeDomParser.System.CodeDom.Compiler.ICodeParser.Parse(TextReader stream)
in System.CodeDom.Compiler.CodeDomProvider.Parse(TextReader codeStream)
in Microsoft.VisualStudio.Shell.Design.Serialization.CodeDom.CodeDomDocDataAdapter.get_CompileUnit()
in Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
in Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload) 

任何帮助都会受到赞赏......

sry:我只是在项目属性中添加默认命名空间,一切正常......

2 个答案:

答案 0 :(得分:1)

只需在项目属性中添加默认命名空间并重新创建表单,或在该特定表单的代码中添加命名空间。

答案 1 :(得分:0)

确保在编辑命名空间之前删除您创建的表单。或者你会不断收到错误。