i'm making application on c# winforms scans documents , places them picturebox, when attempt scan throws exception saying "object reference not set instance of object" , not allow me continue, stack trace below;
to clarify, work project in case gets alarmed of class names.
abdesktop.exe!abdesktop.frmcreditcards.scansetup() line 39 c# abdesktop.exe!abdesktop.frmcreditcards.scanfrontbtn_click(object sender, system.eventargs e) line 94 + 0x8 bytes c# [external code] abdesktop.exe!abdesktop.program.main(string[] args) line 26 + 0x20 bytes c# [external code] this code causing issue;
public void scansetup() { wia.commondialog dialog = new wia.commondialog(); imagefile scannedimage=null; scannedimage = dialog.showacquireimage( wiadevicetype.scannerdevicetype, wiaimageintent.unspecifiedintent, wiaimagebias.maximizequality, formatid.wiaformatpng, true, true, false); scannedimage.savefile("c:/users/reece.cottam/pictures"); } and button executes above code when click event fired
private void scanfrontbtn_click(object sender, eventargs e) { scansetup(); imagefile if = new imagefile(); frontscanbox.image = if.loadfile("scannedimage.png"); } any appreciated.
edit line of code causing error scannedimage.savefile
without information line throws exception, guess it's line scannedimage.savefile(...); since documentation commondialog.showacquireimage(...) states null value may returned. in case, when try operate on variable scannedimage, attempting operate on null reference.
Comments
Post a Comment