I have a project in .NET Core 3.1 and it will not extract an entry.
This is the code that is causing the issue, and it is happening in archive.Entries[i].Extract(archive.Entries[i].FileName);
.
for (int i = 0; i < archive.Entries.Count; i++)
{
if (archive.Entries[i].FileName.EndsWith('/'))
Directory.CreateDirectory(archive.Entries[i].FileName);
else
archive.Entries[i].Extract(archive.Entries[i].FileName);
}
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'SevenZipExtractor.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 (0x80004002 (E_NOINTERFACE)).
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
at SevenZipExtractor.IInArchive.Extract(UInt32[] indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback extractCallback)
at SevenZipExtractor.Entry.Extract(Stream stream)
at SevenZipExtractor.Entry.Extract(String fileName, Boolean preserveTimestamp)
at ConsoleApplication17.ArchiveFile.Extract() in C:\Users\Jose\Documents\GitHub\ConsoleApplication17\ConsoleApplication17\ArchiveFile.cs:line 60
at ConsoleApplication17.ExtractWindow.<>c__DisplayClass4_0.<ExtractWindow_Shown>b__0() in C:\Users\Jose\Documents\GitHub\ConsoleApplication17\ConsoleApplication17\ExtractWindow.cs:line 73
All I have done was install the Nuget package, and replace a old method I had used that involved System.IO.Compression
to this.