473,387 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Resource for MessageBox

I have the following line of C# code:

MessageBox.Show(filesThatDoNotExist, "Files Not Found", MessageBoxButtons.OK);

This line generates the following warning when I select "Run Code Analysis"

CA1303 : Microsoft.Globalization : Form1.btnGenerateDocuments_Click(Object,
EventArgs):Void passes a literal as parameter 2 of a call to
MessageBox.Show(String, String, MessageBoxButtons):DialogResult. Retrieve the
following string argument from a resource table instead: 'Files Not Found'

When the warning talks about:

"Retrieve the following string argument from a resource table instead:
'Files Not Found' "

Are they talking about something that allready exists or a resource I have
to create?

I kept expecting to find something like MessageBoxButtons.Something, but
didn't find anything like that with the string "Files Not Found"

Thanks,
--
Randy
Sep 18 '06 #1
2 6449
Nahh it's whinging about the fact that you are passing a language specific
string to display to the user.
If you say, port your code to Spanish, finding all those literal English
strings will be a pain.
The "Best Practice" is to place the literal string in a resource file and
extract the string from there.

HTH

Simon

"randy1200" <ra*******@newsgroups.nospamwrote in message
news:D5**********************************@microsof t.com...
I have the following line of C# code:

MessageBox.Show(filesThatDoNotExist, "Files Not Found",
MessageBoxButtons.OK);
>
This line generates the following warning when I select "Run Code
Analysis"
>
CA1303 : Microsoft.Globalization :
Form1.btnGenerateDocuments_Click(Object,
EventArgs):Void passes a literal as parameter 2 of a call to
MessageBox.Show(String, String, MessageBoxButtons):DialogResult. Retrieve
the
following string argument from a resource table instead: 'Files Not Found'

When the warning talks about:

"Retrieve the following string argument from a resource table instead:
'Files Not Found' "

Are they talking about something that allready exists or a resource I have
to create?

I kept expecting to find something like MessageBoxButtons.Something, but
didn't find anything like that with the string "Files Not Found"

Thanks,
--
Randy

Sep 18 '06 #2
Hi Randy,

On the CA1303 documentation page, there're some example code demostrates
how to use ResourceManager to load resources:

#Do not pass literals as localized parameters
http://msdn2.microsoft.com/en-us/library/ms182187.aspx

For more information about resources, please refer to following section and
its sub-sections:

#Resources in Applications
http://msdn2.microsoft.com/en-us/library/f45fce5x.aspx

Please reply to let us know whether or not you need further information.
Thank you.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: gabriel | last post by:
Greetings, I am working on a project and cannot choose the best way to achieve this : I got a method which returns an error code like this : DISK_FULL or PERMISSION_DENIED. Those are...
3
by: al | last post by:
Hi, I use a resource file (.resx) to store user's settings such as language and other strings. The problem i'm facing is that when the user changes one of the strings in the resource file, ...
2
by: Chris Murphy via DotNetMonster.com | last post by:
Hi all, I've been strugling with this for the last few days and I'm wonding if any of you have had the same problem or a solution I could consider: I'm embedding a bitmap resource (PNG format) as...
0
by: jcvoon | last post by:
Hi: My application will compile a source code and generate an executable assembly during run time, i'm able to generate the exe, but i don't know the correct way to link a resource file into...
6
by: cql90 | last post by:
Hi All, I have created a folder call Resource within my project, I have added a XML file into the resource folder, and I set the BuildAction property of the XML file to "Embedded Resource". How...
4
by: TCook | last post by:
Hey All, I am building a solution which will have many strings that will need to be localized (i.e. strings for toolbars, strings for different WinForms, strings for messages and error messages,...
2
by: Nader | last post by:
I'm trying to use satellite assemblies in my web application. I got a problem with loading resource files. I have the falowing code: protected ResourceManager GetStrings = new...
9
by: Peter Hartlén | last post by:
I understand that the\n and \r only means something to the C# compiler so when retrieving a line like "Hello\r\nWorld" from a resource file (localized form or self made resource file), it prints...
0
by: MikeY | last post by:
I'm having trouble extaction my image from my resource file using DictionaryEnumerator & ResourceReader. String extractions are good. I've been trying to look online for exact info on this, but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.