在图片中加载PictureBox时出错 [英] Geting Error in loading picturebox in picture

查看:126
本文介绍了在图片中加载PictureBox时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好先生
我正在使用窗口表单应用程序
并将数据保存在ms-access
当我在照片中加载PictureBox时
然后我发现错误:尝试读取或写入受保护的内存.这通常表明其他内存已损坏.并尝试赶上也行不通


代码是这个

Hello Sir
I have using window form application
and save data in ms-access
when i load picturebox in photo
then i found Error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. and try catch also not work


code is this

try
{
opd_photo = new OpenFileDialog(); 
opd_photo.FileName = null;
opd_photo.Filter = "Image Files(*.png; *.jpg; *.bmp)|*.png; *.jpg; *.bmp";
if (opd_photo.ShowDialog() == DialogResult.OK) -------- //HERE I GET ERROR
{
pcb_photo.ImageLocation = opd_photo.FileName;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}



请帮助我.



Please help me.

推荐答案

要对这些事情准确无误是很困难的,但我要说的是您正在尝试打开无效的视频文件. ,并且预览抛出错误.当然,当我尝试使用您的代码时,不会出现此类问题.您是否尝试过查看其他图像?

顺便说一句:您可能会发现值得一看的内容- A FileDialog.Filter所有支持的图像的生成器 [ ^ ]
它提供了一个与当前系统已知的所有图像格式匹配的过滤器字符串.


你好先生
我保存在数据库映像文件中,并保存在文件夹中.
这是一个访问数据库,如果我们使用sql数据库,则它不会显示任何错误并且可以正常工作."


然后问题出在三个地方之一:
1)这是您用来加载然后将图像保存到DB的代码.
2)这是您用于将图像存储在数据库中的字段的数据类型.
3)这是您用来从数据库读取图像并将其保存到磁盘的代码.

在这一点上,我无法分辨-我需要相关的代码片段和数据库字段定义.
但是您写入的文件无效,并且预览会引发错误.
It''s difficult if not impossible to be accurate about these things, but I would say that you are trying to open an invalid video file, and the preview is throwing an error. Certainly, when I try with your code I get no such problem. Have you tried looking at different images?

BTW: You may find this worth looking at - A FileDialog.Filter generator for all supported images[^]
It supplies a filter string which matches all image formats known to your current system.


"hello sir
i am save in database image loction and save in folder.
This is an access database if we take sql database then it not show any error and working fine"


Then the problem is in one of three places:
1) It''s the code you use to load and then save the image to the DB.
2) It''s the datatype of the field you are using to store the image in the DB.
3) It''s the code you are using to read the image from the DB and save it to disk.

At this point, I can''t tell - I need the relevant code fragments and the database field definition.
But the file you have written is invalid, and the preview is throwing an error.


这篇关于在图片中加载PictureBox时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆