Question "Events cannot be set on the object passed to the event binding service..."

derdud

New member
Joined
Oct 9, 2008
Messages
2
Programming Experience
5-10
Quite possibly the most irritating and useless VB.NET design error yet.

I'm developing an application in VB.NET using VS 2005. It originally was using .NET 2.0, but I recently updated it to 3.0 so I could use the WPF RichTextBox in the project. I haven't had a problem with it until this morning. I tried to open the form in design view to make a couple changes to existing controls and was greeted with this useless message:

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.

Events cannot be set on the object passed to the event binding service because a site associated with the object could not be located.

at System.ComponentModel.Design.EventBindingService.EventPropertyDescriptor.SetValue(Object component, Object value)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAttachEventStatement(IDesignerSerializationManager manager, CodeAttachEventStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)

On the Error List, under warnings: "Events cannot be set on the object passed to the event binding service because a site associated with the object could not be located." There is no file specified for this error, and both line and column are 0.

I haven't made any changes to the design or controls on the form. It was working fine yesterday. The really obnoxious thing: the form works fine when running the program. Other forms in this project display in design mode without issue. It's just this one and I can't figure out why.

I pulled an older copy of the form (before the WPF integration) from my SVN and dropped the code from the .vb and .designer.vb files into the current project. The .resx files for this form are identical in both versions. Same error message.

Any ideas as to what causes this error message? I did some searches on google for the message and didn't turn up much.
 
This is a design mode problem and as you have discovered won't affect your application at runtime. The 'Site' the warning mentions is actually an ISite and all controls created at design time have one. This could well be a bug in the IDE.
 
This is a design mode problem and as you have discovered won't affect your application at runtime. The 'Site' the warning mentions is actually an ISite and all controls created at design time have one. This could well be a bug in the IDE.

I was kind of suspecting this myself. One of the hits I got on Google was apparently a bug.

So here's the question: How can I edit the form in design view? Am I limited now to only being able to edit the .design.vb file by hand?
 
It could well be a long task but you need to find out where the code is freaking out and set a condition for that line.

Something like.

VB.NET:
If SomeObject.Site IsNot Nothing Then
 
Some Code That Errors

End If

You can debug at design time but i'm not sure the error will flag up you may have to step through from the beginning. To debug at design time you need to go to project properties on the debug tab hit start external program and navigate to where devenv.exe is.

On the command line arguments place the path to your project includning the project file name : SomeProject.vbproj

Set a break point in the main program and then hit play to open a new VS instance and it will load your project but you will be debugging the project you started it from so the code will break even at design time. Hope that helps.
 
Back
Top