This is a migrated thread and some comments may be shown as answers.

Code analysis warning CA2000 in Designer.cs

1 Answer 193 Views
GridView
This is a migrated thread and some comments may be shown as answers.
BJ
Top achievements
Rank 1
BJ asked on 05 Dec 2013, 09:56 PM
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

1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 10 Dec 2013, 02:36 PM
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.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
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 >>
Tags
GridView
Asked by
BJ
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or