views:

865

answers:

4

I am using Visual Studio 2008 and I get the following error message when trying to open one of my Forms:

Could not find endpoint element with name 'WSHttpBinding_ICommon' and contract 'CommonWCF.ICommon' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.

And the following stack trace

at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializePropertyAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement, CodePropertyReferenceExpression propertyReferenceEx, Boolean reportError) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)

And yet I do have the element suggested in my App.Config and everything works at run-time. However, whenever I try to open the form I get this message, which is not too bad because I can ignore it, but when I do many of the controls (those with anchors on the right side and/or the bottom) are shifted and my grids automatically regain all the columns from their datasource which (the columns) I had previously removed.

Any suggestions/workarounds? Is this a Visual Studio 2008 bug?

+1  A: 

Where are you using the endpoint? Do you really need it there or can you only call on it during runtime? You can use the Component.DesignMode property to determine whether you are in design mode so you can prevent the calls to the endpoint being made. To fully debug your design time experience follow the instructions in this article.

olle
Brilliant. This helped to find the code causing the problem. It seems the moving controls and adding grid columns is a separate issue?
ptutt
A: 

I had a similar error once in a form that tried to make a database call during constructor initialization.

Unfortunately, Component.DesignMode doesn't get set until after the constructor finishes!

Joshua
A: 

I use

        if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
        {
            return;
        }

To check for Design Mode in both the Constructor if it does anything other than InitializeComponent() and the Load Method if it has one.

tdyen
A: 

There's another approach to debug the devenv process (visual studio) in design time, like stated here

This helped when opening form in design mode throws exception (i.e. shows error to user).

veljkoz