C#打印代码 未处理Win32Exception

.Net技术 码拜 9年前 (2015-11-08) 1022次浏览
 void printButton_Click(object sender, EventArgs e)
        {
            CaptureScreen();
            printDocument1.Print();
        }
        //实现C# 打印窗体  
        Bitmap memoryImage;
        private void CaptureScreen()
        {
            Graphics myGraphics = this.CreateGraphics();
            Size s = this.Size;
            memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
            Graphics memoryGraphics = Graphics.FromImage(memoryImage);
            memoryGraphics.CopyFromScreen(
           this.Location.X, this.Location.Y, 0, 0, s);
        }
        private void printDocument1_PrintPage(System.Object sender,
        System.Drawing.Printing.PrintPageEventArgs e)
        {
            e.Graphics.DrawImage(memoryImage, 0, 0);
        }

报这样的错怎么解决
C#打印代码 未处理Win32Exception
代码是网上下载无修改的,同样的文件在另一计算机上运行正常,不知何故。
自己编了些关于打印的代码,发现同样的问题,就是在另一台能编译正常执行,而在那台机上编译就会

解决方案:30分
楼主的电脑上装有打印机吗

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明C#打印代码 未处理Win32Exception
喜欢 (0)
[1034331897@qq.com]
分享 (0)