0

エラー メッセージ:

ファイルまたはアセンブリ 'Interop.WIA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' またはその依存関係の 1 つを読み込めませんでした。不正な形式のプログラムをロードしようとしました。

このソリューションは Windows XP では通常の USB スキャナで正常に動作しますが、上記の Windows 7 (x64) でネットワーク スキャナ (Scangear ツールを使用して検出) でスキャンしようとすると、問題が発生します。

C# コード:

 private void startscan()
        {

            try
            {

                CommonDialogClass dailog = new CommonDialogClass();
                ImageFile imgfile = (ImageFile)dailog.ShowAcquireImage(WiaDeviceType.ScannerDeviceType, WiaImageIntent.UnspecifiedIntent, WiaImageBias.MaximizeQuality,
                FormatID.wiaFormatJPEG, true, true, false);
                string firstname = DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
                string name = scantxtfname.Text.Trim() + ".jpeg";


                string filenamepath = ConfigurationManager.ConnectionStrings["scanfilepath"].ConnectionString.ToString() + firstname + name;

                scanfile.Add(name);
                firstint.Add(Convert.ToInt32(firstname));
                SaveImageToPNGFile(imgfile, filenamepath);



                FileStream stream = new FileStream(filenamepath, FileMode.Open, FileAccess.Read);

                stream.Close();

                DataTable dt = new DataTable();

                dt.Columns.Add("Scaned Files", typeof(string));

                datagridscanedfiles.DataSource = null;

                for (int i = 0; i < scanfile.Count; i++)
                {
                    DataRow r = dt.NewRow();
                    r[0] = scanfile[i].ToString();
                    dt.Rows.Add(r);
                }
                datagridscanedfiles.DataSource = dt;
                datagridscanedfiles.Visible = true;
                int ln = scanfile.Count;

                pictureBox1.ImageLocation = filenamepath;

            }
            catch ( Exception d)
            {

                MessageBox.Show(d.Message);
            }


        }


 private static void SaveImageToPNGFile(ImageFile image, string fileName)
        {
            try
            {
                ImageProcess imgProcess = new ImageProcess();
                object convertFilter = "Convert";
                string convertFilterID = imgProcess.FilterInfos.get_Item(ref convertFilter).FilterID;
                imgProcess.Filters.Add(convertFilterID, 0);
                SetWIAProperty(imgProcess.Filters[imgProcess.Filters.Count].Properties, "FormatID", WIA.FormatID.wiaFormatJPEG);
                image = imgProcess.Apply(image);
                image.SaveFile(fileName);
            }
            catch (Exception er)
            {

                MessageBox.Show(er.Message);
            }

        }

  private static void SetWIAProperty(IProperties properties, object propName, object propValue)
        {
            Property prop = properties.get_Item(ref propName);

            prop.set_Value(ref propValue);
        }

上記の問題を解決する方法を教えてください。

4

2 に答える 2