Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Silverlight5
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,
                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 18-Apr-13 0:42am
Sugu.s486
Edited 18-Apr-13 1:29am
v4
Comments
Neha G. Nagpurkar at 20-Jun-13 7:35am
   
Can I get demo application for this? I have been searching for last 2 weeks. Thanks in advance.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Maybe the examples here can help you out:
http://blog.yezhucn.com/wiaaut/showacquireimage.htm[^]
 
Good luck!
  Permalink  
Comments
Sugu.s at 18-Apr-13 7:05am
   
Hi Nijboer,
 
I was tried all these parameters in ShowAcquireImage Method. But not working.
E.F. Nijboer at 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 at 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 at 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 at 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
E.F. Nijboer at 22-Apr-13 7:27am
   
I really wouldn't have any idea because there is to little info on what the problem might be. Have you checked the event log?
Sugu.s at 24-Apr-13 4:26am
   
I got error when access scanner
 
Message: Unhandled Error in Silverlight Application Failed to create an object instance for the specified ProgID.
at MS.Internal.Error.MarshalXresultAsException(UInt32 hr, COMExceptionBehavior comExceptionBehavior)

at MS.Internal.XcpImports.CheckHResult(UInt32 hr)

at MS.Internal.ComAutomation.ComAutomationNative.CreateObject(String progID, IntPtr& nativeObject)

at MS.Internal.ComAutomation.ComAutomationServices.CreateObject(String progID, ComAutomationParamWrapService paramWrapService)

at System.Runtime.InteropServices.Automation.AutomationFactory.CreateObject(String progID)

at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)
E.F. Nijboer at 24-Apr-13 4:54am
   
Have you tried google on the first line? ;-)
 
http://10rem.net/blog/2010/04/14/scanning-an-image-from-silverlight-4-using-wia-automation
Sugu.s at 24-Apr-13 5:26am
   
Thanks for response.
I don't want to know how to set OOB in Silverlight 4. My requirement is elevated trust and in browser together for Silverlight 5 web application.
E.F. Nijboer at 24-Apr-13 6:03am
   
Wouldn't the example work in sl5 too?
Sugu.s at 24-Apr-13 5:27am
   
I have another issue. If i browse with Run as Administrator on windows 7, everything working fine. At same time i was not able to get either function to work on machine (windows XP). How to work with windows XP.
E.F. Nijboer at 24-Apr-13 6:03am
   
http://stackoverflow.com/questions/11678646/enabling-in-browser-elevated-trust
 
http://xamlgeek.net/2011/04/20/silverlight-5-elevated-trust-in-browser/
Angela 10293848 at 23-Jan-14 1:44am
   
Hi
could you resolve the problem with windows xp?I have a same problem,my code dose not work on windows sp
E.F. Nijboer at 23-Jan-14 7:50am
   
If the answer isn't in one of the links already I would suggest to "Ask a Question" yourself here on codeproject, explaining your situation with some more details.
Angela 10293848 at 23-Jan-14 8:34am
   
I have problem in xp not in browser
E.F. Nijboer at 23-Jan-14 9:59am
   
It would be better to create your own question because this is not the place to post a question. You could mention this question if it would help making your own question more clear but your problem is OS related and this is browser related, so not really the same problem actually.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Sugu,
 
To work in IE, Just change ElevatedPermissions="Required" in InBrowserSettings.xml
code
<InBrowserSettings>
  <InBrowserSettings.SecuritySettings>
    <SecuritySettings ElevatedPermissions="Required" />
    <!--<SecuritySettings ElevatedPermissions="NotRequired" /> This is default-->
  </InBrowserSettings.SecuritySettings>
</InBrowserSettings>
  Permalink  
Comments
Sugu.s at 17-Dec-13 0:56am
   
Hi, already the ElevatedPermissions set as Required.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Another approach can be using a web-based scanner ActiveX/plugin. Here [^] is a demo app you can try.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 6,569
1 Sergey Alexandrovich Kryukov 6,168
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 25 Mar 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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