private static System.Drawing.Image ReadBitmapFromResource(string ResName, Assembly ResAssembly){ string ResFileName; if (ResAssembly.FullName.IndexOf(',') > 0) { ResFileName = string.Format("{0}.Properties.Resources.resources", ResAssembly.FullName.Substring(0, ResAssembly.FullName.IndexOf(','))); } else { ResFileName = string.Format("{0}.Properties.Resources.resources", ResAssembly.FullName); } using (ResourceReader ResReader = new ResourceReader(ResAssembly.GetManifestResourceStream(ResFileName))) { string ResType; byte[] ResByte; ResReader.GetResourceData(ResName, out ResType, out ResByte); if (ResType != null && ResByte != null ? ResType.IndexOf("System.Drawing.Bitmap") == 0 : false) { using (MemoryStream ResStream = new MemoryStream(ResByte)) { return (Image)(new BinaryFormatter().Deserialize(ResStream)); } } } return null;}
...System.Reflection.Assembly assembly=System.Reflection.Assembly.LoadFrom("PNGResource.dll");if (assembly != null){ Image LargeIcon = ReadBitmapFromResource("LargeIcon", assembly); Image SmallIcon = ReadBitmapFromResource("SmallIcon", assembly);}...