C# (WINFORMS)运行起来后 出现GDI+一般性错误
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace MainFormapp
{
public partial class AdminForm : Form
{
private int id = 0;
public AdminForm()
{
InitializeComponent();
}
private void AdminForm_Load(object sender, EventArgs e)
{
//全屏
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
getimg();
}
private void getimg()
{
IList<getimgsResult> il = new List<getimgsResult>();
List<Image> l = new List<Image>();
using (TempDataContext obj = new TempDataContext())
{
il = obj.getimgs().ToList();
foreach (getimgsResult item in il)
{
byte[] b = item.img.ToArray();
MemoryStream ms = new MemoryStream(b, 0, b.Length, true);
Image img = Image.FromStream((Stream)ms);
l.Add(img);
ms.Close();
}
}
this.pictureBox1.Image = l[0];
this.pictureBox2.Image = l[1];
this.pictureBox3.Image = l[2];
this.pictureBox4.Image = l[3];
this.pictureBox17.Image = l[4];
this.pictureBox18.Image = l[5];
this.pictureBox8.Image = l[6];
this.pictureBox7.Image = l[7];
this.pictureBox6.Image = l[8];
this.pictureBox5.Image = l[9];
this.pictureBox12.Image = l[10];
this.pictureBox11.Image = l[11];
this.pictureBox10.Image = l[12];
this.pictureBox20.Image = l[13];
this.pictureBox19.Image = l[14];
this.pictureBox9.Image = l[15];
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void 添加用户ToolStripMenuItem_Click(object sender, EventArgs e)
{
AdduserForm add = new AdduserForm();
add.ShowDialog();
}
private void button13_Click(object sender, EventArgs e)
{
this.openFileDialog1.ShowDialog();
}
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
using(TempDataContext obj=new TempDataContext())
{
obj.setvideopath(this.openFileDialog1.FileName);
}
}
private void button1_Click(object sender, EventArgs e)
{
this.id = 1;
this.openFileDialog2.ShowDialog();
}
private void openFileDialog2_FileOk(object sender, CancelEventArgs e)
{
try
{
string path = this.openFileDialog2.FileName;
FileInfo fi = new FileInfo(path);
byte[] b = new byte[fi.Length];
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
fs.Read(b, 0, b.Length);
fs.Close();
using (TempDataContext obj = new TempDataContext())
{
try
{
obj.setimg(new System.Data.Linq.Binary(b), this.id);
}
catch (Exception)
{
MessageBox.Show("设置失败");
return;
}
}
MessageBox.Show("设置成功");
getimg();
}
catch (Exception)
{
MessageBox.Show("文件读取错误");
return;
}
}
private void button2_Click(object sender, EventArgs e)
{
this.id = 2;
this.openFileDialog2.ShowDialog();
}
private void button3_Click(object sender, EventArgs e)
{
this.id = 3;
this.openFileDialog2.ShowDialog();
}
private void button4_Click(object sender, EventArgs e)
{
this.id = 4;
this.openFileDialog2.ShowDialog();
}
private void button8_Click(object sender, EventArgs e)
{
this.id = 7;
this.openFileDialog2.ShowDialog();
}
private void button7_Click(object sender, EventArgs e)
{
this.id = 8;
this.openFileDialog2.ShowDialog();
}
private void button6_Click(object sender, EventArgs e)
{
this.id = 9;
this.openFileDialog2.ShowDialog();
}
private void button18_Click(object sender, EventArgs e)
{
this.id = 5;
this.openFileDialog2.ShowDialog();
}
private void button19_Click(object sender, EventArgs e)
{
this.id = 6;
this.openFileDialog2.ShowDialog();
}
private void button5_Click(object sender, EventArgs e)
{
this.id = 10;
this.openFileDialog2.ShowDialog();
}
private void button12_Click(object sender, EventArgs e)
{
this.id = 11;
this.openFileDialog2.ShowDialog();
}
private void button11_Click(object sender, EventArgs e)
{
this.id = 12;
this.openFileDialog2.ShowDialog();
}
private void button10_Click(object sender, EventArgs e)
{
this.id = 13;
this.openFileDialog2.ShowDialog();
}
private void button21_Click(object sender, EventArgs e)
{
this.id = 14;
this.openFileDialog2.ShowDialog();
}
private void button20_Click(object sender, EventArgs e)
{
this.id = 15;
this.openFileDialog2.ShowDialog();
}
private void button9_Click(object sender, EventArgs e)
{
this.id = 16;
this.openFileDialog2.ShowDialog();
}
}
}
在线等啊。。。。 QQ78116846