CyberUnDead
asked on
FXCop Do not pass literals as localized parameters
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("~/Repor t/Report1. aspx")
End Sub
Protected Sub Report2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Report2.Click
Response.Redirect("~/Repor t/Report2. aspx")
End Sub
Protected Sub Report3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Report3.Click
Response.Redirect("~/Repor t/Report3. aspx")
End Sub
'---End Code---
What is the proper way to either code the above or eliminate the error message from FxCop?
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("~/Repor
End Sub
Protected Sub Report2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Report2.Click
Response.Redirect("~/Repor
End Sub
Protected Sub Report3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Report3.Click
Response.Redirect("~/Repor
End Sub
'---End Code---
What is the proper way to either code the above or eliminate the error message from FxCop?
ASKER
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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<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