Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a very small C# program and uses ResXResourceWriter class, but it always got compilation error:
the type or namespace name 'ResXResourceWriter' could not be found (are you missing a using directive or an assembly reference?)

The code is simple and uses Visual Studio 2008 on Vista Ultimate:
//================================================================
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Resources;
using System.Drawing;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {

            ResXResourceWriter rw = new ResXResourceWriter("Demo.resx");

            using (Image image = Image.FromFile("logo.gif"))
            {
                rw.AddResrouce("WroxLogo", image);
                rw.AddResource("Title", "Professional C#");
                rw.AddResource("chapter", "Localizeation");
                rw.AddResource("Author","You guys");
                rw.AddResource("Publisher", "Test Publisher");
            }
        }
    }
}
Posted
Updated 29-Mar-22 20:58pm
Comments
Sergey Alexandrovich Kryukov 14-Feb-15 23:07pm    
First of all, why would you do it, AddResource? The purpose of embedded resource is pretty much obvious to what you are doing.
—SA

Two things. One, the error message is giving you a rather large hint about what's wrong.

Taking a look at the documentation on ResXResourceWriter, here[^], will tell you exactly what you're missing.

It says that you need to import the System.Resources namespace, which is found in the System.Windows.Forms assembly.

Normally, in a Windows Forms app, you don't have to set a reference to the assembly because it's already there automatically. But, since you're writing a Console application, you have to explicitly add a Reference to the System.Windows.Forms assembly. After that you simply add the line "using System.Resources" to the top of your code file.
 
Share this answer
 
Comments
Southmountain 14-Feb-15 16:46pm    
thank you very much! you resolved my issue.

now I see the statement in that link:
=======================================================================
Namespace: System.Resources
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Member 15024740 2-Aug-21 4:32am    
thnx great its working
Use System.resource.netstanders from nugit package ResXResourceReader.NetStanderds
 
Share this answer
 
Comments
Richard Deeming 30-Mar-22 3:35am    
There is no such package.

And even if you spell it correctly, a package that relates to .NET Standard is not relevant to an already-solved question about Visual Studio 2008.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900