các bạn xem hộ mình cái lỗi này nhé
One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.
Object reference not set to an instance of an object.
Hide
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyNa me assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at Microsoft.VisualStudio.Design.VSTypeResolutionServ ice.AssemblyEntry.get_Assembly()
at Microsoft.VisualStudio.Design.VSTypeResolutionServ ice.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly, String description)
at Microsoft.VisualStudio.Design.VSTypeResolutionServ ice.SearchNormalEntries(AssemblyName assemblyName, String typeName, Boolean ignoreTypeCase, Assembly& assembly)
at Microsoft.VisualStudio.Design.VSTypeResolutionServ ice.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, ReferenceType refType)
at Microsoft.VisualStudio.Design.Serialization.CodeDo m.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.Serialization.CodeDo m.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError)
at System.ComponentModel.Design.Serialization.CodeDom SerializerBase.GetType(ITypeResolutionService trs, String name, Dictionary`2 names)
at System.ComponentModel.Design.Serialization.CodeDom SerializerBase.FillStatementTable(IDesignerSeriali zationManager manager, IDictionary table, Dictionary`2 names, CodeStatementCollection statements, String className)
at System.ComponentModel.Design.Serialization.TypeCod eDomSerializer.Deserialize(IDesignerSerializationM anager manager, CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDom DesignerLoader.PerformLoad(IDesignerSerializationM anager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDo m.VSCodeDomDesignerLoader.PerformLoad(IDesignerSer ializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDe signerLoader.BeginLoad(IDesignerLoaderHost host)
thanks
Time
Lỗi là do method InitializeComponent() có 1 hay nhiêu dòng gây lỗi, rất hay gặp nếu bạn dùng điều khiển tự tạo và ít kinh nghiệm,lưu ý là các public property luôn đc serialize lên nếu các lệnh trong property này có sử dụng các object chưa khởi tạo sẽ sinh error, mặc dù nhiều trường hợp chạy thì ok,nhưng ko mở design ra đc.
solution:
- Kiểm tra lại mục reference , xóa các mục có chấm than màu vàng ( nếu có )rồi reference lại
- rebuild project
- Đóng VS và mở lại
- Kiểm tra lại đoạn khởi tạo của user control, catch exeption trong tất cả public property
- Nếu vẫn ko đc thì tạo 1 form mới copy code sang.