Microsoft FxCop 1.312

G

Guest

In the report of the FxCop analysis:

CriticalError, Certainty 95, for
"TypesThatOwnDisposableFieldsShouldBeDisposable"
{
Target : "Receiver" (IntrospectionTargetType)
Resolution : "Implement IDisposable on 'Receiver' as it instantiates members
of the following IDisposable types: System.Net.Sockets.Socket"
Help :
"http://www.gotdotnet.com/team/fxcop...hatOwnDisposableFieldsShouldBeDisposable.html" (String)
Category : "Microsoft.Design" (String)
RuleFile : "Design Rules" (String)
Info : "Types that declare disposable members should also implement
IDisposable. If the type does not own any unmanaged resources, do not
implement a finalizer on it."
Status : Active (MessageStatus)
Fix Category : Breaking (FixCategories)
}

But Socket has the Dispose method as protected so I can not invoke it.
Should I or shouldn't I Implement IDisposable in this case???
 
N

Nicole Calinoiu

The protected Socket.Dispose method that takes a boolean is not actually the
Socket's implementation of the IDisposable.Dispose method. Socket uses an
explicit implementation, so you would need to cast to IDisposable to call
Dispose. However, the Socket.Close method does exactly this, so you can
simply call that instead.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top