-1

これで例外が発生しましたが、誰でも私を助けることができますか?

Exception:Unable to cast COM object of type 'System.__ComObject' to interface type 'SevenZip.IInArchive'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{23170F69-40C1-278A-0000-000600600000}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))

コード:

private void UnZip(string zipToExtract, string unzipDirectoryl) // Extract zip/lot file in same directory
    {

            #region Extraction test - ExtractFiles
            using (var tmp = new SevenZipExtractor(zipToExtract))
            {
                if (this.progressBar1.InvokeRequired)
                {
                    progressBar1.Invoke(new Action(delegate()
                    {
                        progressBar1.Maximum = tmp.ArchiveFileData.Count;
                        progressBar1.Value = 0;
                    }));
                }
                else
                {
                    progressBar1.Maximum = tmp.ArchiveFileData.Count;
                    progressBar1.Value = 0;

                }
                for (int i = 0; i < tmp.ArchiveFileData.Count; i++)
                {
                    tmp.ExtractFiles(unzipDirectoryl, tmp.ArchiveFileData[i].Index);

                    int tempval = 0,tot=0;
                    if (this.progressBar1.InvokeRequired)
                    {
                        progressBar1.Invoke(new Action(delegate() { progressBar1.Value++; tempval = progressBar1.Value; progressBar1.Refresh(); tot = progressBar1.Maximum; }));
                    }
                    else
                    {
                        progressBar1.Value++; //pseudo-code
                        progressBar1.Refresh();
                        tempval = progressBar1.Value;
                        tot = progressBar1.Maximum;
                    }
                    //progressBar1.Value += 1;
                    //progressBar1.Refresh();

                    if (this.label3.InvokeRequired)
                    {
                        label3.Invoke(new Action(delegate() { label3.Text = ((tempval * 100) / (tot)).ToString(); label3.Refresh(); }));
                    }
                    else
                    {
                        label3.Text = ((tempval * 100) / (tmp.ArchiveFileData.Count)).ToString();
                        label3.Refresh();
                    }
                    if (!tmp.ArchiveFileData[i].IsDirectory)
                    {
                        FileInfo f = new FileInfo(unzipDirectoryl + "\\" + tmp.ArchiveFileData[i].FileName);
                        if (f.Length == 0)
                        {
                            status("Error :Zero byte file observed: \\" + tmp.ArchiveFileData[i].FileName, Color.Red);
                        }
                    }
                }
                // To extract more than 1 file at a time or when you definitely know which files to extract,
                // use something like
                //tmp.ExtractFiles(@"d:\Temp\Result", 1, 3, 5);
            }

            #endregion

    } 

私は独自の解決策を得ました:この変更により、完璧なアウトプットが得られますが、なぜですか?

int temp= tmp.ArchiveFileData.Count;
if (this.progressBar1.InvokeRequired)
            {
                progressBar1.Invoke(new Action(delegate()
                {
                    progressBar1.Maximum = temp;
                    progressBar1.Value = 0;
                }));
            }
4

1 に答える 1

1

例外から抜け出すのに役立ちます:

int temp= tmp.ArchiveFileData.Count;
if (this.progressBar1.InvokeRequired)
        {
            progressBar1.Invoke(new Action(delegate()
            {
                progressBar1.Maximum = temp;
                progressBar1.Value = 0;
            }));
        }
于 2013-04-24T05:40:00.903 に答える