FXCop Do not pass literals as localized parameters

Posted on 2007-10-10
Last Modified: 2013-11-26
I have developed an ASP.NET web application and I ran FXCop against my .dll in my bin directory.

I am receiving several Non Breaking "Do not pass literals as localized parameters" Errors.
Clicking on the link takes me to but I am still not certain on how to correct this notice.

For instance this aspx page contains three buttons which in return redirects the user to the appropriate report depending upon what button they clicked.   The code below is flagged three times for the aforementioned "Do not pass literals..." error.  I am using VB.NET as my langauge of choice.

'---Begin Code---
    Protected Sub Report1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Report1.Click
    End Sub

    Protected Sub Report2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Report2.Click
    End Sub

    Protected Sub Report3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Report3.Click
    End Sub
'---End Code---

What is the proper way to either code the above or eliminate the error message from FxCop?
Question by:CyberUnDead
    LVL 96

    Expert Comment

    by:Bob Learned
    Here is a point from that article:

    <Quote>It is safe to exclude a warning from this rule if the code library will not be localized, or if the string is not exposed to the end user or a developer using the code library.</Quote>

    It is saying that you can ignore that warning.  If you want to deal with it, then you need to store the string in a resource file, and pull the value from there.


    Author Comment


    Thanks for the quick reply.  If I were to go with the second option of correcting the notice instead of ignoring it.  Do you have an example or tutorial on using resource files?  Does it make sense to do so since I do have about 70 notices of this particular error?
    LVL 96

    Accepted Solution

    1) FxCop is very restrictive, and trying to accomodate every single warning is counter-productive, in my opinion.

    2) If you aren't going to localize the strings, then you can ignore that level of warning.

    3) Here is an example of setting up localization:
    .NET - Localization using Resource file

    4) The hoop that you need to jump through to get this working, if you aren't using localization, is a perfect example of a counter-productive pursuit.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now