luuksommers / sevenzipsharp.interop Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
I'm using Visual Studio 2022, the dll is not copyed to the output dir.
This seems like a bug to me but maybe it's just my lack of understanding how it should work. When I try to extract a single file the library seems to process the entire archive rather than just the single file. In my case I have an archive with one very large file and a bunch of little texts files (10). I try to extract one of the small text files and I have the "FileExtractionStarted" event fire 11 messages (one for each file in the archive) instead of just one total. That also means the "FileExtractionFinished" event fires 11 times and the "Extracting" event fires an excessive amount of times as well (once by percent update but for each file)!
Using 7zipFM I can extract the single file in a few milliseconds. Using this method it takes about 30 seconds. This becomes a huge problem when I use the same method to extract almost all the files. It then sends a "FileExtractionStarted" event for each file in the archive during EACH file actually being extracted!
I'm using the following code...
private void SevenZipExtractor_Extracting(object sender, ProgressEventArgs e)
{
//Only update every 20%
if (e.PercentDone % 20 == 0)
System.Diagnostics.Debug.WriteLine("SevenZipExtractor_Extracting -- " + e.PercentDone + "%");
}
private void SevenZipExtractor_FileExtractionFinished(object sender, FileInfoEventArgs e)
{
System.Diagnostics.Debug.WriteLine("SevenZipExtractor_FileExtractionFinished -- " + e.PercentDone + "% Filename:" + e.FileInfo.FileName);
}
private void SevenZipExtractor_FileExtractionStarted(object sender, FileInfoEventArgs e)
{
System.Diagnostics.Debug.WriteLine("SevenZipExtractor_FileExtractionStarted -- " + e.PercentDone + "% Filename:" + e.FileInfo.FileName);
}
private void DecompressThread(string archiveFilePath, string localPath)
{
//archiveFilePath is the path of the 7z archive
//localPath is the path of the newly extracted text file from the 7z archive
byte[] fileInBytes = File.ReadAllBytes(archiveFilePath);
using (MemoryStream inStream = new MemoryStream(fileInBytes))
{
using (SevenZipExtractor extractor = new SevenZipExtractor(inStream))
{
extractor.Extracting += SevenZipExtractor_Extracting;
extractor.FileExtractionStarted += SevenZipExtractor_FileExtractionStarted;
extractor.FileExtractionFinished += SevenZipExtractor_FileExtractionFinished;
using (FileStream file = new FileStream(localPath, FileMode.Create, FileAccess.Write))
{
//Extract a single file
// I know and have checked the extractor.ArchiveFileData[4] data
// to ensure it's the small text file I want to extract
extractor.ExtractFile(4, file);
}
extractor.Extracting -= SevenZipExtractor_Extracting;
extractor.FileExtractionStarted -= SevenZipExtractor_FileExtractionStarted;
extractor.FileExtractionFinished -= SevenZipExtractor_FileExtractionFinished;
}
}
}
Here are the results of the events I get from the Library (results_of_archive_extraction.txt). It seems to extract the single text file as I would expect but when doing so is VERY slow because it tries to process the entire file instead of just the one file.
I have a question opened on stackoverflow with more information.
Hi Luuk.
Your project seems to be missing a license and therefore your project is under exclusive copyright.
Because of this no one can legally copy, modify or distribute your work.
We would very much like to use your work and I would suggest that you put the project under the same license as 7z.
I would also suggest to mention 7z and link to their license for good measure.
https://www.7-zip.org/license.txt
Best regards, Mark.
Everything works fine in the development process when the SevenZipSharp.dll is not packed. But after I packed the whole application into an executable program, this exception occurred.
This is the code.
var libraryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "7z.dll");
SevenZip.SevenZipBase.SetLibraryPath(libraryPath);
SevenZip.SevenZipExtractor extractor = new SevenZipExtractor(stream);
Using 7z.dll version 18.5.0.0.
Exception: Wartość nie może być zerowa. (eng: **Vallue cannot be null**)
Nazwa parametru: ptr (Name of parameter: ptr)
StackTrace: in System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer(IntPtr ptr, Type t)
in SevenZip.SevenZipLibraryManager.OutArchive(OutArchiveFormat format, Object user)
in SevenZip.SevenZipCompressor.SetCompressionProperties()
in SevenZip.SevenZipCompressor.GetArchiveUpdateCallback(Stream inStream, String password)
in SevenZip.SevenZipCompressor.CompressStream(Stream inStream, Stream outStream, String password)
It gets randomly, catched in in 1/100 times of packing same input data.
I am using multithreading on independent source and output streams:
using (var compressedStream = new MemoryStream())
{
SevenZipBase.SetLibraryPath(@"7z.dll");
SevenZipCompressor compressor = new SevenZipCompressor { CompressionLevel = SevenZip.CompressionLevel.Fast };
compressor.CompressStream(inputStream, compressedStream);
return compressedStream.ToArray();
}
Hi, i like to run a command line app in the cloud, but the 7z.dll which is added by me to the project with 'always copy' doesn't end up in the target folder on the webapp after publish. That way, preventing the app to run. Any clue what i need to set in my vs project to use the 7dll that way ?
Note: the same happend when i was trying to use the 7dll in an Azure Function.
I would like to use this package in a platform project, but it is not allowed:
Error Could not install package 'SevenZipSharp.Interop.NoReferences 19.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Could you indicate if this should be possible or not?
7zip 19.0 adaptation request.
Maybe some simple chm file with examples on the usage
with api documentation would be a huge add on for this
also I suggest it could be available for GAC installations like VS extention or even zip file have the built binaries?
and please do not remove support for .net 2, 3.5 and 4 winform and wpf
.Net standard or . Net5
For better performance.
Hi
Thanks for making this library
Just wondering whether SevenZipSharp is also required to use this library.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at SevenZip.SevenZipLibraryManager.InitUserOutFormat(Object user, OutArchiveFormat format)
at SevenZip.SevenZipLibraryManager.LoadLibrary(Object user, Enum format)
at SevenZip.SevenZipCompressor.CompressStream(Stream inStream, Stream outStream, String password)
Using in multi threads at same time:
using (var compressedStream = new MemoryStream())
{
SevenZipCompressor compressor = new SevenZipCompressor { CompressionLevel = SevenZip.CompressionLevel.Fast };
compressor.CompressStream(memoryStream, compressedStream); //Exception in this line
return compressedStream.GetBuffer();
}
Also in same time was shown: Managed Debugging Assistant 'RaceOnRCWCleanup' An attempt has been made to free an RCW that is in use. The RCW is in use on the active thread or another thread. Attempting to free an in-use RCW can cause corruption or data loss.
Looks like problem of multi-threaded access? Maybe use ConcurrentDictionary?
If there is no access to the file, catch is not caught with the application crashing and text in the debugger -
System.Reflection.TargetInvocationException: "The destination of the call threw an exception."
Internal exception:
UnauthorizedAccessException: Access denied on path "......".
Currently, the latest library from nuget is used. If a file or folder is available, everything works.
System.Transactions Critical: 0 : http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/UnhandledНеобработанное исключениеProgramm.exeSystem.Reflection.TargetInvocationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089The destination of the call threw an exception. в System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
в System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
в System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
в SevenZip.SevenZipBase.AsyncCallbackMethod(IAsyncResult ar)
в System.Runtime.Remoting.Messaging.AsyncResult.SyncProcessMessage(IMessage msg)
в System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
в System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
в System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
в System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
в System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
в System.Threading.ThreadPoolWorkQueue.Dispatch()
в System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()System.Reflection.TargetInvocationException: The destination of the call threw an exception. ---> System.UnauthorizedAccessException: Access denied on path "...".
Server stack trace:
в SevenZip.SevenZipBase.ThrowException(CallbackBase handler, Exception[] e)
в SevenZip.SevenZipBase.CheckedExecute(Int32 hresult, String message, CallbackBase handler)
в SevenZip.SevenZipCompressor.CompressFilesEncrypted(Stream archiveStream, Int32 commonRootLength, String password, String[] fileFullNames)
в SevenZip.SevenZipCompressor.CompressFilesEncrypted(String archiveName, Int32 commonRootLength, String password, String[] fileFullNames)
в SevenZip.SevenZipCompressor.CompressFiles(String archiveName, String[] fileFullNames)
в System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
в System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
Exception rethrown at [0]:
в System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
в System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
в SevenZip.SevenZipCompressor.CompressFiles1Delegate.EndInvoke(IAsyncResult result)
в System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
в System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
в System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
в SevenZip.SevenZipBase.AsyncCallbackMethod(IAsyncResult ar)
в System.Runtime.Remoting.Messaging.AsyncResult.SyncProcessMessage(IMessage msg)
в System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
в System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
в System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
в System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
в System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
в System.Threading.ThreadPoolWorkQueue.Dispatch()
в System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()System.UnauthorizedAccessException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089Access denied on path "...".
Server stack trace:
в SevenZip.SevenZipBase.ThrowException(CallbackBase handler, Exception[] e)
в SevenZip.SevenZipBase.CheckedExecute(Int32 hresult, String message, CallbackBase handler)
в SevenZip.SevenZipCompressor.CompressFilesEncrypted(Stream archiveStream, Int32 commonRootLength, String password, String[] fileFullNames)
в SevenZip.SevenZipCompressor.CompressFilesEncrypted(String archiveName, Int32 commonRootLength, String password, String[] fileFullNames)
в SevenZip.SevenZipCompressor.CompressFiles(String archiveName, String[] fileFullNames)
в System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
в System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
Exception rethrown at [0]:
в System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
в System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
в SevenZip.SevenZipCompressor.CompressFiles1Delegate.EndInvoke(IAsyncResult result)System.UnauthorizedAccessException: Access denied on path "...".
Server stack trace:
в SevenZip.SevenZipBase.ThrowException(CallbackBase handler, Exception[] e)
в SevenZip.SevenZipBase.CheckedExecute(Int32 hresult, String message, CallbackBase handler)
в SevenZip.SevenZipCompressor.CompressFilesEncrypted(Stream archiveStream, Int32 commonRootLength, String password, String[] fileFullNames)
в SevenZip.SevenZipCompressor.CompressFilesEncrypted(String archiveName, Int32 commonRootLength, String password, String[] fileFullNames)
в SevenZip.SevenZipCompressor.CompressFiles(String archiveName, String[] fileFullNames)
в System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
в System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
Exception rethrown at [0]:
в System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
в System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
в SevenZip.SevenZipCompressor.CompressFiles1Delegate.EndInvoke(IAsyncResult result)
I've tried to use this package with Squid-Box.SevenZipSharp
.
Due to dependencies included inside package it keep installing the original sevenZipSharp package.
There is a way to use your interop packages with forked packages?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.