开发者

'.ctor' is not a valid identifier

In visual studio 2008 when open the design for a VB.Net windows form, i am getting the error " '.ctor' is not a valid identifier". I can see the form designer if I press the "Ignore and Continue" link.

All other forms are loading fine.

The callstack with the error message:

at Microsoft.VisualStudio.Shell.Design.Serialization.CodeDom.CodeDomEventBindingService.ValidateMethodName(String methodName)
at System.ComponentModel.Design.EventBindingService.EventPropertyDescriptor.SetValue(Object component, Object value)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAtta开发者_如何学运维chEventStatement(IDesignerSerializationManager manager, CodeAttachEventStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)

Any idea on how to fix this?


This message may indicate that you accidently have overwritten the constructor. As far as I know, M$ VStudio instanciates your form to display it in the designer window.

Maybe the following steps will help

  • Check, if you have a Sub with your class name defined in your .vb-file (for example: "Private Sub YOURCLASS (...) Handles MyBase.Load" instead of "Private Sub YOURCLASS_load (...) Handles MyBase.Load" )
  • go into the Solution Explorer (nice name, isn't it)
  • rebuild the whole solution

Best regards


A very simple solution would be rebuilding the form from scratch and that probably won't give an error. The Visual Studio designer sometimes create code the designer itself won't understand.

Some other steps to make sure you're not watching an old designer dll file.

Close the designer for the file Clean the project and rebuild Start the application Open the designer

This should force the designer to reload the file.

The designer also seems to block all network traffic, if you do anything with remoting/webservices it probably won't work and cause unexpected error while designing.


In my case, this error came when I had declared a constructor but hadn't defined it. You can check for the same in your code.


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


Private Sub Form1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

tenia repetido handles MyBase.load

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜