Click here to Skip to main content
14,423,257 members
Rate this:
Please Sign up or sign in to vote.
See more:
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) 

''I am getting issue on above line

            MessageBox.Show("4")
            'imageObject.SaveFile(fileName)
            'Byte[] imageBytes = (byte[])imageObject.FileData.get_BinaryData();
            Dim imageBytes As Byte() = imageObject.FileData.BinaryData()
            ' <– Converts the ImageFile to a byte array
            Dim ms As New MemoryStream(imageBytes)

            'System.Drawing.Image image = System.Drawing.Image.FromStream(ms);

            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]
Posted
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

First
1.please check that the scanner has WIA drivers
2.The application you are running on the machine has installed WIA drivers.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100