Strange behaviour re. the IDE

We have a winforms application and some of the forms have properties etc.

When viewing certain forms, sometimes the 'ErrorForm' we have created pops up like it would at runtime saying a property has not been initialized, it actually pops up as a window like it would show at runtime

Also I note after some changes to a separate project, namely adding a static class with a static method that returns a connection string. We can no longer view certain user controls as the IDE shows with the following error

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.

The ConnectionString property has not been initialized.

Hide

at System.Data.SqlClient.SqlConnection.PermissionDemand()
at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at DBDescriptionEditor.SqlHelper.ExecuteDataset(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters) in C:\Source\NPDAAT2007\Development\NPDAAT\Forvus.NPDAAT.DataAccess\SQLHelper.cs:line 428
at DBDescriptionEditor.SqlHelper.ExecuteDataset(String connectionString, CommandType commandType, String commandText) in C:\Source\NPDAAT2007\Development\NPDAAT\Forvus.NPDAAT.DataAccess\SQLHelper.cs:line 407
at Forvus.NPDAAT.DataAccess.ModificationReasonDataManager.GetAllModificationReasons() in C:\Source\NPDAAT2007\Development\NPDAAT\Forvus.NPDAAT.DataAccess\ModificationReasonDataManager.cs:line 16
at Forvus.NPDAAT.Business.ModificationReasonManager.GetAllmodificationReasons() in C:\Source\NPDAAT2007\Development\NPDAAT\Forvus.NPDAAT.Business\ModificationReasonManager.cs:line 20

I have tried to look at the modification reason manager class and there appears to be nothing wrong. The DBDescriptionEditor.SqlHelper.ExecuteDataset has not been changed however we are now passing into it the static method that we created returned string, instead of a hardcoded DB string. After creating this class the problems have started.



Answer this question

Strange behaviour re. the IDE

  • DineshB

    Hi,
    most probably you have code that is executed on Design Time and that code is failing for some reason, for example if you've added code at OnLoad method which is trying to establish a connection or something like this, this code will be executed when the form is showed in Vs.

    To avoid that you should check the property DesignMode like this:

    protected override void OnLoad(EventArgs e)
    {
    base.OnLoad(e);

    if (!this.DesignMode)
    {
    // Do something
    }
    }

    hope it helps


  • CurtisDeHaven

    Well that is indeed the problem. There is a method in the OnLoad that populates a dropdown list by getting values from the database.

    I won't put the fix around it I will comment out that line of code at design time so I can still view the form.

    Thanks


  • Gabi M


    Thanks

  • Rolan

    Zamial,

    Report the bug using http://connect.microsoft.com/

    Pablo



  • Strange behaviour re. the IDE