473,757 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Microsoft FxCop 1.312

In the report of the FxCop analysis:

CriticalError, Certainty 95, for
"TypesThatOwnDi sposableFieldsS houldBeDisposab le"
{
Target : "Receiver" (IntrospectionT argetType)
Resolution : "Implement IDisposable on 'Receiver' as it instantiates members
of the following IDisposable types: System.Net.Sock ets.Socket"
Help :
"http://www.gotdotnet.c om/team/fxcop/docs/rules.aspx?vers ion=1.312&&url=/Design/TypesThatOwnDis posableFieldsSh ouldBeDisposabl e.html" (String)
Category : "Microsoft.Desi gn" (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???
--
Thanks
Sharon
Nov 17 '05 #1
1 1961
The protected Socket.Dispose method that takes a boolean is not actually the
Socket's implementation of the IDisposable.Dis pose 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.

"Sharon" <Sh****@discuss ions.microsoft. com> wrote in message
news:25******** *************** ***********@mic rosoft.com...
In the report of the FxCop analysis:

CriticalError, Certainty 95, for
"TypesThatOwnDi sposableFieldsS houldBeDisposab le"
{
Target : "Receiver" (IntrospectionT argetType)
Resolution : "Implement IDisposable on 'Receiver' as it instantiates
members
of the following IDisposable types: System.Net.Sock ets.Socket"
Help :
"http://www.gotdotnet.c om/team/fxcop/docs/rules.aspx?vers ion=1.312&&url=/Design/TypesThatOwnDis posableFieldsSh ouldBeDisposabl e.html"
(String)
Category : "Microsoft.Desi gn" (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???
--
Thanks
Sharon

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1527
by: Crocker Data Processing | last post by:
Hi. I've written a bunch of custom rules for FxCop version 1.23, and today happened to download and install (separately) the new FxCop 1.321. Arrgghh ! The new introspection stuff is a lot nicer, but I will have to move my rules over. Fair enough, but I notice that there is still no documentation for the SDK, I understand that's because there may be
0
1311
by: Chua Wen Ching | last post by:
Hi there, I am super confuse on this recommendation by FxCop. 1) http://www.gotdotnet.com/team/fxcop/docs/rules/UsageRules/OperatorEqualsOverridesRequireEqualsOverridel.html First of all, let me explain how i see that problem: I had a C program that does this:
2
2952
by: Uri Dor | last post by:
Hi, everyone, The question is whether there is (or can be) an FxCop rule that makes sure I don't do this: String.Format("{0}-{1}-{2}", 5); Or similar things. Some explanations: 1) of course I only mean cases where the format string is a constant string literal in the code - that's 99% of the cases anyway 2) similar cases are Console.Write(), etc., I know
7
1960
by: steve bull | last post by:
If I create an array, e.g. private int x, inside a parent class whose elements can be accessed by a child class - what is the recommended way of doing this? When I create a property for the array FxCop complains that properties should not return arrays. If I want to make the array private, which FxCop insists I do as well, is the only way of accessing the array elements via a method? See e.g....
8
1898
by: hansiman | last post by:
Just beginning using FxCop in my asp.net projects... I get a lot of error messages under the header: AvoidUnusedParameters for funtions and routines lik: Sub isUserAuthenticated(ByVal blnLoggedIn As Boolean) If Not (blnLoggedIn) Then System.Web.HttpContext.Current.Response.Redirect(pcPageLogin) End If
4
379
by: Bruce One | last post by:
Given a project with some .cs files, Is there a way to block some of these files to be read by FxCop ?
10
1723
by: Karsten Schramm | last post by:
I would write BaseClass var; ..... if(var is DerivedClass) { DerivedClass derivedVar = (DerivedClass)var; DoSomething(derivedVar); }
6
1371
by: John Wright | last post by:
I ran FxCop against a program and was pleased with the security review except I get the following error: Do not indirectly expose methods How would I fix this code so this error goes away. I think I understand the error, but not the fix. I really need to fix this as it is called from other programs and I do not want code elevating privileges in this function. Thanks.
3
4381
by: AlexS | last post by:
When I implement Dispose pattern in object implementing IDisposable, current fxcop recommends: Ensure that Wrapper.Dispose():Void is declared as public and sealed. However, if I do as it asks, compiler complains that sealed can't be used because method is not overrideable. I believe sealed isn't applicable here at all. And this rule shouldn't be public virtual in this case.
0
9487
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10069
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7285
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6556
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.