locked
Code Analysis Error with VS 2008 Sillverlight Project RRS feed

  • Question

  • Hi

    I am getting these errors while running Code Analysis on my Silverlight Application in VS 2008 SP1

    Error 7 CA1823 : Microsoft.Performance : It appears that field 'Page.LayoutRoot' is never used or is only ever assigned to. Use this field or remove it. C:\Silverlight.Controls\obj\Debug\Page.g.cs 38 Silverlight.Controls
    Error 8 CA1823 : Microsoft.Performance : It appears that field 'ProductTree.addProduct' is never used or is only ever assigned to. Use this field or remove it. C:\Silverlight.Controls\obj\Debug\MyTree.g.cs 58 Silverlight.Controls

     Here LayoutRoot is the root Grid and addProduct is a Button, XAML for same is

    <Button Name="addProduct" Content="Add Product(s)" Width="100" Click="addProduct_Click"></Button>

    click event "addProduct_Click" is defined in code behind page.

    If I remove the "Name=addProduct" attribute of addProduct button the Code Analysis error message disappears. I don't think it should be proper to remove Name Attribute from all buttons.

    Please tell me how can I supress these Code Analysis errors.

    -- Irfan 

     

    Tuesday, April 21, 2009 3:16 AM

Answers

  • Delete these control's Name(or x:Name, x:Key) attribute. 

    when you assign name to controls, the related .g.cs file will generate object reference to controls automaticly.

    Monday, April 27, 2009 5:49 AM

All replies

  • It should be x:Name not Name

     

    Tuesday, April 21, 2009 5:53 AM
  • Hi Ken,

    Tried x:Name too, it has the same effect Sad

    Tuesday, April 21, 2009 6:05 AM
  • Delete these control's Name(or x:Name, x:Key) attribute. 

    when you assign name to controls, the related .g.cs file will generate object reference to controls automaticly.

    Monday, April 27, 2009 5:49 AM