We help IT Professionals succeed at work.

FXCop Do not pass literals as localized parameters

CyberUnDead
CyberUnDead asked
on
484 Views
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 http://msdn2.microsoft.com/en-us/library/904d284e-76d0-4b8f-a4df-0094de8d7aac(vs.80).aspx 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
        Response.Redirect("~/Report/Report1.aspx")
    End Sub

    Protected Sub Report2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Report2.Click
        Response.Redirect("~/Report/Report2.aspx")
    End Sub

    Protected Sub Report3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Report3.Click
        Response.Redirect("~/Report/Report3.aspx")
    End Sub
'---End Code---

What is the proper way to either code the above or eliminate the error message from FxCop?
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
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.

Bob

Author

Commented:
TheLearnedOne:

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?
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.