Program.cs里的Application.Run(new Form1());语句报异常了。。
不知道为什么。这代码都是自动生成的。。
请问这是怎么回事?
未处理 System.Reflection.TargetInvocationException
由于以前的函数求值超时,函数求值被禁用。必须继续执行才能重新启用函数求值。
我在代码里用过委托有关系吗?

解决方案 »

  1.   

    Application.Run(new Form1());弹出异常,并不是这句错了,往往是你相应的窗体中,有某些严重错误检查你的代码
      

  2.   

    我做的有个主界面。界面里有个ListBox控件
    我写了个类
    里面有个静态的ListBox对象
    我在类里又写了一个方法设置类里的ListBox    class setList
        {
            private static ListBox listMessage=null;        public static void SetList(ref ListBox listbox)
            {
                listMessage = listbox;
            }
            public static void Add(string str)
            {
                listMessage.BeginInvoke(new additem(ListAdd), new string[] { str });
            }        private delegate void additem(string str);
            private static void ListAdd(string str)
            {
                listMessage.Items.Add(str);
                FileTxt.Write(str);
            }
        }然后在窗体加载事件里用
    setList.SetList(ref listMessage);
    设置了一下。然后就可以
    用类里的Add方法往界面里添加了。。这样有错误吗?
      

  3.   

    大概是我在别的类的构造方法里用了setList.Add("aaa");的关系
      

  4.   

    FileTxt.Write(str);//怎么实现的
      

  5.   

    烦请各位:看看下面这段代码:
    在 img.SetPixel(i, j, color);处出现如图所示的错误:
    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.Windows;
    private void button11_Click(object sender, EventArgs e)
            {
                pictureBox1.Load("F:\\图片\\Photos\\mp4图片\\200809.jpg");
                pictureBox1.Update();
               //以油画效果显示图像
                Graphics g = this.panel1.CreateGraphics();
                //Bitmap bitmap = this.MyBitmap;
                //取得图片尺寸
                Bitmap MyBitmap;
                MyBitmap = (Bitmap)this.pictureBox1.Image.Clone();
                int width = MyBitmap.Width;
                int height = MyBitmap.Height;
                RectangleF rect = new RectangleF(0, 0, width, height);
                Bitmap img = MyBitmap.Clone(rect, System.Drawing.Imaging.PixelFormat.DontCare);
                //产生随机数序列
                Random rnd = new Random();
                //取不同的值决定油画效果的不同程度
                int iModel = 2;
                int i = width - iModel;
                while (i > 1)
              {
                int j = height - iModel;
                   while (j > 1)
                    {
                        int iPos = rnd.Next(100000) % iModel;
                        //将该点的RGB值设置成附近iModel点之内的任一点
                        Color color = img.GetPixel(i + iPos, j + iPos);
                        img.SetPixel(i, j, color);
                        j = j - 1;
                    }
                    i = i - 1;
                }
                //重新绘制图像
                g.Clear(Color.White);
                g.DrawImage(img, new Rectangle(0, 0, width, height));         }