日期:2014-05-18  浏览次数:21966 次

未能找到任何适合于指定的区域性或非特定区域性的资源。请确保在编译时已将“Jayn.API.Jayn.resources”正确嵌入或链接到程序集“Jayn.API”,或者确保所有需要的附属程序集都可加载
创建一个资源文件
C# code


    public class CreatResource
    {
        //System.Windows.Forms.Application.StartupPath+
        private static string Skin_Path = Environment.CurrentDirectory + "\\Skin\\";//皮肤文件夹路径
        /// <summary>
        /// 创建资源文件
        /// </summary>
        public static bool Create()
        {
            if (!System.IO.File.Exists("Jayn.resources"))
            {
                ResourceWriter rw = new ResourceWriter("Jayn.resources");//创建一个资源文件
                try
                {
                    Image Top_Left = Image.FromFile(Skin_Path + "Top_Left.gif");
                    rw.AddResource("Top_Left.gif", Top_Left);
                    rw.Generate();
                    rw.Close();
                    return true;
                }
                catch
                {
                    rw.Close();
                    return false;
                    throw new ArgumentException(Skin_Path);
                }
            }
            return true;


        }


    }




读取资源文件

C# code


try
            {
                CResource = CreatResource.Create();创建一个资源文件

                if(CResource)
                {
                    rm = new ResourceManager("Jayn.API.Jayn", System.Reflection.Assembly.GetExecutingAssembly());
                    //读取图片
                    Top_Left = (Bitmap)rm.GetObject("Top_Left.gif");
                  }


            }
            catch (Exception e) { throw new ArgumentException(e.Message); }




资源文件是创建成功了的。

错误提示:未能找到任何适合于指定的区域性或非特定区域性的资源。请确保在编译时已将“Jayn.API.Jayn.resources”正确嵌入或链接到程序集“Jayn.API”,或者确保所有需要的附属程序集都可加载并已进行了完全签名。

------解决方案--------------------
你需要把第一个CS的实体传给你的Main(第二个) 在第二
public Main() 

InitializeComponent(); 
//这里接收第一个CS的实体


------解决方案--------------------
把obj文件夹和bin文件夹从,项目文件里移除即可!!!!