Code analysis warning CA2000 in Designer.cs

2 posts, 0 answers
  1. BJ
    BJ avatar
    3 posts
    Member since:
    Apr 2013

    Posted 05 Dec 2013 Link to this post

    I am getting a code analysis warning from the generated GridView code in the Designer.cs file for my user controls.  The error reads as follows:

    In method 'MyControl.InitializeComponent()', object 'gridViewTextBoxColumn1' is not disposed along all exception paths. Call System.IDisposable.Dispose on object 'gridViewTextBoxColumn1' before all references to it are out of scope.

    I know that I can use a SuppressMessage attribute, but it's appearing anywhere I use a GridView and I'd rather not litter my code with a bunch of suppressions.  Is there another way to fix this?

    Visual Studio 2012 Ultimate
    C#, .NET 4.0
    Telerik for Windows Forms 2013.2 724
  2. George
    George avatar
    500 posts

    Posted 10 Dec 2013 Link to this post

    Hello BJ,

    Thank you for contacting us.

    Currently, this is how the designer code is being generated and there is no way to work around it if you are going to use the designer. The only possible workaround except ignoring/suppressing the warning is to add your columns at runtime. To avoid putting the SuppressMessage attribute, you can suppress a warning for an entire project by going to Project -> Properties -> Build and putting the warning numbers in the Suppress warnings field.

    Let me know if you have any further questions.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top