Hi Guys,
I am not able to scan using WIA after deploying my web application in IIS 7.5
I tried this in Windows 7 and Server 2012.
Even "ScanImage" function is not calling . When comment the line "ShowAcquireImage" then application calling ScanImage function otherwise it displays message as waiting for response in browser.
Any help is highly appreciated.
Below is my function for scanning.
<securitypermission(securityaction.demand,> _
Public Function ScanImage(ByVal outputFormat As ImageFormat, ByVal fileName As String) As System.Drawing.Image
If outputFormat Is Nothing Then
Throw New ArgumentNullException("outputFormat")
End If
MessageBox.Show("1")
Dim filePerm As New FileIOPermission(FileIOPermissionAccess.AllAccess, fileName)
filePerm.Demand()
MessageBox.Show("2")
Dim imageObject As ImageFile = Nothing
Try
If WiaManager Is Nothing Then
WiaManager = New CommonDialogClass()
End If
MessageBox.Show("3")
imageObject = WiaManager.ShowAcquireImage(WiaDeviceType.ScannerDeviceType, WiaImageIntent.ColorIntent, WiaImageBias.MinimizeSize, outputFormat.Guid.ToString("B"), True, False, False)
MessageBox.Show("4")
Dim imageBytes As Byte() = imageObject.FileData.BinaryData()
Dim ms As New MemoryStream(imageBytes)
Dim bmp As New Bitmap(System.Drawing.Image.FromStream(ms))
Dim fileName1 As String = "D:\VBTest111.jpg"
bmp.Save(fileName1, ImageFormat.Jpeg)
Return System.Drawing.Image.FromFile(fileName1)
Catch ex As COMException
Dim message As String = "Error scanning image"
Throw New WiaOperationException(message, ex)
Finally
If imageObject IsNot Nothing Then
Marshal.ReleaseComObject(imageObject)
End If
End Try
End Function
[Edit member="Tadit"]
Added
pre
tags.
[/Edit]