| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 813 人关注过本帖
标题:我这个"制作使用的资源文件"的程序怎么都找不到哪错了?
只看楼主 加入收藏
sageking2
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-8-19
收藏
 问题点数:0 回复次数:0 
我这个"制作使用的资源文件"的程序怎么都找不到哪错了?
我先这样做一个名为MyResources.resources的资源文件

C# code
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;//调用图片必须的
using System.Resources;
using

namespace Class1
{
    class Program
    {
        static void Main(string[] args)
        {//temp.jpg拖入该文件夹下运行会生成一个资源文件
            ResourceWriter rw = new ResourceWriter("MyResources.resources");//将资源文件存入MyResources.resources文件中            
            Image Img = Image.FromFile("temp.jpg");
            rw.AddResource("MyPic", Img);//再加图片比*.exe文件更易加上
            string Mystr = "I love China.";
            rw.AddResource("MyString", Mystr);           
            //rw.Generate();//以系统默认的format保存所有的资源
            rw.Close();
        }
    }
}




在开一个使用资源文件的程序,然后先 Project->Add Existing Items->添加MyResources.resource文件后去Solution Explorer里右击设置其Build Action属性为Embedded(嵌进) Resource.Form1.cs里敲入下面代码:

C# code
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Resources;//使用资源文件要用的
using System.Reflection;
using

namespace 使用自制的资源文件
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }  
        ResourceManager rm = new ResourceManager("MyResources", Assembly.GetExecutingAssembly());//初始化资源管理对象MyResources是资源文件名      
        private void btn_Img_Click(object sender, EventArgs e)
        {//从资源文件提取图片并显示
            MyPic.Image = (Image)rm.GetObject("MyPic");
        }

        private void btn_Str_Click(object sender, EventArgs e)
        {//从资源文件提取字符串
            string str = (string)rm.GetString("MyString");
            MessageBox.Show(str);
        }
    }
}



Debug运行后出现Error:
Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "MyResources.resources" was correctly embedded or linked into assembly "使用自制的资源文件" at compile time, or that all the satellite assemblies required are loadable and fully signed.

然后,我用MSIL Disassember反编译了下"使用自制的资源文件.exe"在MANIFEST里找到了下面
.mresource public '使用自制的资源文件.MyResources.resources'
{
  // Offset: 0x00000000 Length: 0x0000BC7F
}
说明嵌入资源没错啊!!!!!!!我是见鬼了,怎么都调不出来
----------------------------------------------------------------------------------------------------
问过很多人都是绕过问题的,谁能帮我做这个实验,其实只要两个按钮一个PictureBox就搞定的...
搜索更多相关主题的帖子: 资源 文件 制作 
2008-09-05 11:01
快速回复:我这个"制作使用的资源文件"的程序怎么都找不到哪错了?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020874 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved