Questions tagged [ca2000]

25 questions
1
vote
0 answers

warning : CA2000 : Microsoft.Reliability call System.IDisposable.Dispose despite of using

In the following method i get the warning: warning : CA2000 : Microsoft.Reliability : In method 'AvdfileCache.AddPartTableGaugeData(long, long)', call System.IDisposable.Dispose on object 'cmdGaugeData' before all references to it are out of…
suriel
  • 191
  • 1
  • 10
1
vote
2 answers

How to fix this CA2000 for SqlCommand?

I'm trying to execute a SQL query like following, but Visual Studio complains a CA2000. public static IDictionary TemplateDirectories(string connectionString) { var directories = new Dictionary(); using (var…
Yue Wang
  • 1,710
  • 3
  • 18
  • 43
1
vote
1 answer

CA2000 - "out-of-school-junior-programmers"-mistakes or false positive?

I am currently developing some desktop applications using websockets (to be more precisely: i am working with Alchemy WebSockets). By now my code is working fine, but Visual Studio 2010 tells me to Warning 2 CA2000 : Microsoft.Reliability : In…
Matthias R.
  • 441
  • 2
  • 15
1
vote
1 answer

Code Analysis Complains about "CA2000 Dispose objects before losing scope" when I Don't Dispose My MDI Child Form

CA2000 Dispose objects before losing scope In method FormMain.barButtonItem1_ItemClick(object, ItemClickEventArgs) Call System.IDisposable.Dispose on object 'frm' before all references to it are out of scope. Winpro FormMain.cs 32 Method :…
Carlo
  • 151
  • 1
  • 3
  • 16
0
votes
1 answer

Returning disposable object and getting CA2000 warning

I am trying to return XMLNodeReader to another function but getting CA2000 warning XmlNodeReader obj =new XmlNodeReader(section); return ser.method(obj); If I use the following code, will it work properly? The warning is supressed but not sure if…
user3386619
  • 31
  • 1
  • 5
0
votes
1 answer

CA2000 warning on Class Level Object

I have an object that is declared at the class level which is giving CA2000 warning. How can I get rid of the CA2000 warning from the code below? public partial class someclass : Window { System.Windows.Forms.OpenFileDialog dlg = new…
0
votes
2 answers

Code Analysis : CA2000 warnings

I have following code with six CA2000 warnings. and i get this warning when i do code analysis. please let me know how to overcome this warning and why i get this warning. please do help me how to clear this warning and thanks in advance. if…
0
votes
1 answer

CA2000 warning on returned value

I know this has been discussed many times but no solutions seems to work so I thought and may be worth a try to reopen it since some time has passed. I have a function: Public Function Test() As Object Dim retVal As DisposableObject Dim…
0
votes
2 answers

CA2000/CA2202 for Stream in a using statement

CA2000 and CA2202 warnings have recently been the bane of my existence. What am I doing wrong here? I basically get a FileStream using File.Open and then pass it into a function that may return a new stream or may return the same stream. I then…
sohum
  • 3,207
  • 2
  • 39
  • 63
0
votes
1 answer

CA2000 and returned Socket object: how to solve?

I have next function: public static Socket ConnectSocket(string srvName, int srvPort) { Socket tempSocket = null; IPHostEntry hostEntry = null; try { hostEntry = Dns.GetHostEntry(srvName); …
Ksice
  • 3,277
  • 9
  • 43
  • 67
1
2