[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

FXCop Do not pass literals as localized parameters

Posted on 2007-10-10
3
Medium Priority
?
453 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?
0
Comment
Question by:CyberUnDead
  • 2
3 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20050516
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
0
 

Author Comment

by:CyberUnDead
ID: 20050818
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?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 20051032
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
http://www.codeproject.com/dotnet/Localization.asp

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.

Bob
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month20 days, 7 hours left to enroll

868 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