0

我正在 C# 中的 visualstudio10 中开发一个项目。制作表单后,我尝试将另一个表单添加到项目中,但 VS 无法打开设计器,也无法为表单创建正确的文件它只是创建了一个名为“form2.cs”的文件和另一个名为“form2.cs”的文件。 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:我只是在项目属性中添加了默认命名空间,一切正常......

4

2 回答 2

1

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

于 2012-04-11T06:16:38.573 回答
0

确保在编辑命名空间之前删除您创建的表单。否则您将不断收到错误消息。

于 2013-11-24T19:00:05.283 回答