Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
2.25/5 (3 votes)
See more:
Hi I work Silverlight 5 and use the following code for scanning, it works fine on win 8 but on windows xp it dose not work,
can anyone assistance me?

C#
private void Button_Click_1(object sender, RoutedEventArgs e)
      {
          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);
              }
          }

      }
Posted
Updated 25-Jan-14 0:53am
v3
Comments
OriginalGriff 25-Jan-14 7:00am    
Reason for my vote of one: don't bump your question, it's rude.
By all means use the Improve Question to add information, but just adding a few blank lines to move it back to the top of the list is not "improving it".
Angela 10293848 25-Jan-14 7:03am    
no way?!

Check if the scanner library is registered on the Windows XP machine.
Also ensure the right version of Silverlight is available on that machine.
 
Share this answer
 
Comments
Angela 10293848 25-Jan-14 7:06am    
Thanks for your reply,Silverlight is enabled on that machine because other section is work only scanning does not work, but how can I register scanner library on XP?
• Change the reg key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Silverlight debugging value to 1
 
Share this answer
 
v2
If silverlight is enabled or registry is set to 1 thn may be you have not configured your scanner in windows xp since it is default in windows 8.


Click "Start," then "Control Panel." Click "Classic View" in the left column if applicable.

Double-click "Scanners and Cameras."

Right-click your camera or scanner. Click "Properties."

Click the "Events" tab.

Click "Camera connected" in the "Event" drop-down menu.

Click "Start this program" under the "Actions" header.

Click "Microsoft Scanner and Camera Wizard" in the drop-down menu to the right of "Start this program."

Click "Apply," then "OK.
 
Share this answer
 
Comments
Angela 10293848 25-Jan-14 7:26am    
I can access scanner device with other windows application on xp, but with above code it does not work
finally I added wiaaut.dll in win Xp and registered it, now it works
 
Share this answer
 

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