Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have used vs2010 and silverlight 5 to access scanner in web browser. When i host the application on iis7, i can able to access scanner in Mozilla but does not in internet explorer. why the IE browser does not support to access scanner in web browser?

I made changes in,
Server side
• Sign the xap using certificate.
Client side
• Install the cert into “trusted publishers”
• Change the reg key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Silverlight \AllowElevatedTrustAppsInBrowser” to 1

My code is,
C#
try
{
    using (dynamic CommonDialog = AutomationFactory.CreateObject("WIA.CommonDialog"))
    {
        dynamic imageFile = CommonDialog.ShowAcquireImage();
        if (imageFile != null)
        {
            if (!Directory.Exists("D:\\ScanImage"))
            {
                Directory.CreateDirectory("D:\\ScanImage");
            }
            string filePath = string.Format("D:\\ScanImage\\{0}.jpg", Guid.NewGuid());
            imageFile.SaveFile(filePath);
        }
    }
}
catch (System.Runtime.InteropServices.COMException ex)
{
    if (ex.ErrorCode == -2145320939)
    {
        MessageBox.Show("Could not find an attached scanner.", "Scanner Error", MessageBoxButton.OK);
    }
    else
    {
        MessageBox.Show(ex.Message, "Scanner Error", MessageBoxButton.OK);
    }
}

Thanks in advance
Posted
Updated 18-Apr-13 0:29am
v4
Comments
Neha G. Nagpurkar 20-Jun-13 7:35am    
Can I get demo application for this? I have been searching for last 2 weeks. Thanks in advance.

Maybe the examples here can help you out:
http://blog.yezhucn.com/wiaaut/showacquireimage.htm[^]

Good luck!
 
Share this answer
 
Comments
Sugu.s 18-Apr-13 7:05am    
Hi Nijboer,

I was tried all these parameters in ShowAcquireImage Method. But not working.
E.F. Nijboer 18-Apr-13 7:16am    
Maybe this info helps, there seems to be another reg key:
http://msdn.microsoft.com/en-us/library/gg192793%28v=vs.95%29.aspx
Sugu.s 18-Apr-13 7:40am    
If i open browser with Run as Administrator (with Administrator permissions), able to access scanner. do you have any idea without admin permission to access.
E.F. Nijboer 18-Apr-13 8:21am    
Seems you need to give non-admin users the correct permission. There is some info on that on the above link, like info on Group Policy Settings. I don't know exactly whats wrong. It is also strange that Firefox does work, or are you always running that as administrator?
Also have a look here:
http://msdn.microsoft.com/en-us/library/ee721083%28v=vs.95%29.aspx
Sugu.s 22-Apr-13 7:15am    
I was tried all group policy settings and all above given link details, nothing to work. Any idea tell me ASAP
Sugu,

To work in IE, Just change ElevatedPermissions="Required" in InBrowserSettings.xml
code
HTML
<InBrowserSettings>
  <InBrowserSettings.SecuritySettings>
    <SecuritySettings ElevatedPermissions="Required" />
    <!--<SecuritySettings ElevatedPermissions="NotRequired" /> This is default-->
  </InBrowserSettings.SecuritySettings>
</InBrowserSettings>
 
Share this answer
 
Comments
Sugu.s 17-Dec-13 0:56am    
Hi, already the ElevatedPermissions set as Required.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900