WinForm. Designer.cs in-code throw reflection exception

Source: Internet
Author: User
Tags stack trace

Today, after adding a control to a WinForm within a project, you cannot open it, throwing the following exception.

System.Reflection.TargetInvocationException:Exception have been thrown by the target of a invocation. ---> System.NullReferenceException:Object reference not set to a instance of an Object.
At CM. CTOS. VesselDocument.CovCodControl.InitializeComponent () in C:\test\testform.designer.cs:line 2547
At CM. CTOS. Vesseldocument.covcodcontrol. ctor () in C:\test\testform.cs:line 153
At CM. CTOS. VesselDocument.CovCodForm.InitUserControl () in C:\test\testform.cs:line 58
At CM. CTOS. Vesseldocument.covcodform. ctor () in C:\test\testform.cs:line 43
---End of inner exception stack trace---
At System.RuntimeTypeHandle.CreateInstance (RuntimeType type, Boolean publiconly, Boolean NoCheck, boolean& Canbecached, runtimemethodhandle& ctor, boolean& Bneedsecuritycheck)
At System.RuntimeType.CreateInstanceSlow (Boolean publiconly, Boolean FillCache)
At System.RuntimeType.CreateInstanceImpl (Boolean publiconly, Boolean skipvisibilitychecks, Boolean FillCache)
At System.Activator.CreateInstance (type type, Boolean nonpublic)
At System.Activator.CreateInstance (type type)
At CM. CTOS. WinUIAdmin.MenuManager.SubMenuClick (Object sender, EventArgs e) in C:\test\menumanager.cs:line 267

After checking, the error code is: Designer.cs:line 2547. This code is automatically generated by VisualStudio and there is no reason to make an error.

Later, I was reminded by my colleague When I open the Testform.resx file, VisualStudio hints that there are duplicates, after my new control, I renamed the control (only the case of the first name), which caused the testform.resx to appear with different case names, and after purging the obsolete items, WinForm normal.

This should be a VisualStudio bug.

WinForm. Designer.cs in-code throw reflection exception

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.