7

I got below violation in FxCop. when I hard code the string in Console.WriteLine("Service Started");

Method 'method()' passes a literal string as parameter 'value' of a call to 'Console.WriteLine(string)'. Retrieve the following string(s) from a resource table instead: "Service Started"

So I changed the code like below type.

ResourceManager rm = new ResourceManager("Service Started", Assembly.GetExecutingAssembly());
string start = rm.GetString("Service Started");
Console.WriteLine(start);

Now I do not get the FxCop violation. But I got the below exception in the line string start = rm.GetString("Service Started");

How can I fix this exception?

Additional information: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Service Started.resources" was correctly embedded or linked into assembly "namespace name" at compile time, or that all the satellite assemblies required are loadable and fully signed.

1 Answers1

4

It seems that you might not have added a resource string and value. Please verify the below links for reference:

Code Analysis using VS.Net 2010

How to create and use resources in .NET

adamj537
  • 677
  • 7
  • 14
Dilip
  • 474
  • 2
  • 8
  • 18