请注意关键的是“资源”,类应该对应更复杂的结构。例子:从assembly文件中提供程序需要的图像http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/servingimages.asp

解决方案 »

  1.   

    C#生成并引用资源文件可以使用任何信息,图片,字符,尤其是图片信息,比DLL要广泛得多。下面创建一个资源文件using System;
    using System.Resources;
    using System.Drawing;namespace ConsoleApplication1
    {
    /// <summary>
    /// Class1 的摘要说明。
    /// </summary>
    class Class1
    {
    /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main(string[] args)
    {
    ResourceWriter rw = new ResourceWriter(@"D:\ConsoleApplication1\obj\Debug\wwww.resources");
    using (Image image = Image.FromFile(@"D:\ConsoleApplication1\obj\Debug\logo.gif"))
    {/*
      * 在 using 语句中创建一个实例,确保退出 using 语句时在对象上调用 Dispose。
      * 当到达 using 语句的末尾,
      * 或者如果在语句结束之前引发异常并且控制离开语句块,都可以退出 using 语句。
      * 
      */ rw.AddResource("WroxLogo", image);
    rw.AddResource("Title", "Professional C#");
    rw.AddResource("Chapter", "Assemblies");
    rw.AddResource("Author", "Christian Nagel");
    rw.AddResource("Publisher", "Wrox Press");
    rw.Close();
    }
    }
    }
    }例外一个工程中下面代码装载上面创建的资源Assembly assembly = Assembly.GetExecutingAssembly(); rm = new System.Resources.ResourceManager("WindowsApplication1.wwww",assembly); logo.Image = (Image)rm.GetObject("WroxLogo");
    textBoxTitle.Text = rm.GetString("Title");
    textBoxChapter.Text = rm.GetString("Chapter");
    textBoxAuthor.Text = rm.GetString("Author");
    textBoxPublisher.Text = rm.GetString("Publisher");
      

  2.   

    你可以把需要的string或者图片放入资源文件,这样你就可以通过改变资源文件的方式来改变程序的结果了。
    Generated Access to .NET Resource Strings
    http://www.codeproject.com/csharp/genresourcekeys.asp?target=%2Eresource资源文件常用来解决本地化问题
    .NET - Localization using Resource file
    http://www.codeproject.com/dotnet/Localization.asp?target=%2Eresource
      

  3.   

    那么如何才能用VS.NET 的IDE操作这个资源文件呢,好像打开里面全是二进制代码,它跟VS.NET所生成的.resx的文件是不是属于同一类,VS.NET生成的.resx的文件好像是XML结构的,有谁能详细说明一下呢
      

  4.   

    resx只是一个form的结构定义罢了,当然,你可以在定义的时候给某个控件加上名称属性之类的。但是这些东西在compile之后就无法修改了,而resouce里面的信息就不同了,因此我们用.resource文件来实现本地化。Run resource generator utility on this resource file by using the Visual Studio .NET command prompt. The command for generating a .resources file is:Resgen MyResource.en-GB.resxThis will create a binary version of the above resource file named, MyResource.en-GB.resources.