Code Monkey home page Code Monkey logo

sevenzipsharp.interop's People

Contributors

fr1z2r avatar luuksommers avatar roadtrain avatar spiridonovalexmoedelo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sevenzipsharp.interop's Issues

When extracting single file from archive "FileExtractionStarted", "Extracting" and "FileExtractionFinished" event show all files extracting.

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.

Missing license

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.

Exception occurs when loading library in a standalone WPF application

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.
image
This is the code.

var libraryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "7z.dll");
SevenZip.SevenZipBase.SetLibraryPath(libraryPath);
SevenZip.SevenZipExtractor extractor = new SevenZipExtractor(stream);

Pointer value cannot be null exception

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();
                    }

cant deploy on azure webapp

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.

Can't install in .net platform project

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?

documentation for novices is needed

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

Exception: Element with same key already exists

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?

File not available does not catch

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)

Using this package with other version of SevenZipSharp

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.