[RESOLVED]Head block of Master Pages triggers "CA2000 : Microsoft.Reliability" Warning

I ran code-analysis on my website and got a whole string of warnings that make no sense to me.

First, here is the warning I received: 

Warning 16 CA2000 : Microsoft.Reliability : In method ‘about_us_masterpage_master.__BuildControl__control2()’, object ‘__ctrl’ is not disposed along all exception paths. Call System.IDisposable.Dispose on object ‘__ctrl’ before all references to it are out
of scope. C:UsersHank_LimitedDocumentsVisual Studio 2010WebSitesFinmanAssociatesAbout_UsMasterPage.master 8 C:…FinmanAssociates

I bolded each of the lines which triggered a warning.  As you can see from the full page code I pasted below, I don’t have any script blocks — it’s all off-the-shelf Visual Studio 2010 work here.

Does anyone have any idea why I’m getting this warning?

<head runat="server"> 
    <title>[Redacted]</title>  
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
    <link href="../Styles/Main.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/Menu.css" rel="stylesheet" type="text/css" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
</head>

<%@ Master Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>[Redacted]</title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
    <link href="../Styles/Main.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/Menu.css" rel="stylesheet" type="text/css" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
</head>
<body>
    <form id="form1" runat="server">
    <div id="div_Frame">
        <div id="div_Header">
            <p>[Redacted]</p>
        </div>
        <div id="div_Middle">
            <div id="div_Menu">
                <asp:SiteMapDataSource ID="smdsRoot" runat="server" />
                <asp:Menu ID="mvRoot" runat="server" DataSourceID="smdsRoot" Orientation="Horizontal"
                    StaticDisplayLevels="2" MaximumDynamicDisplayLevels="0" StaticEnableDefaultPopOutImage="False">
                    <StaticMenuItemStyle CssClass="MenuItemStyle" />
                </asp:Menu>
            </div>
            <div id="div_Body">
                <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">                    
                </asp:ContentPlaceHolder>
            </div>
        </div>
        <div id="div_Footer">
            <p>[Redacted]</p>
        </div>
    </div>
    </form>
</body>
</html>

Hi,

According to your description and the error message, this warning is a false positive. You can try to  turn CA2000 off in your project because of these false positives. You can make some break points to debug steps by steps, to find which row will throw
this error message.

There is a similar thread, please refer to the link below:

http://stackoverflow.com/questions/9738061/ca2000-on-method-using-using-but-not-using-try-finally

Hope it’s useful for you.

Best Regards,

Michelle Ge

Leave a Reply