[
  {
    "Id": "1131698",
    "ThreadId": "471895",
    "Html": "Hi,<br />\n<br />\nI recently tried to automate an SFX creation with DotNetZip and PowerShell. Procedure is as following:<br />\n<ol>\n<li>Loading Ionic.Zip.dll</li>\n<li>Reading in configuration from a file</li>\n<li>Validating configuration input</li>\n<li>Following you will find the proceeding relevant code snippets:</li>\n</ol>\n<pre><code>   #&lt;...&gt; defines where I cut some code\n   #&lt;some initializing variable setting&gt;\n        $private:dll = &quot;$private:currentPath\\Ionic.Zip.dll&quot;\n        [void][System.Reflection.Assembly]::LoadFrom($private:dll)\n   #&lt;Steps 2-3&gt;\n        try {\n            $private:zipfile =  new-object Ionic.Zip.ZipFile\n        } catch [Exception] {\n   #&lt;handling exception&gt;\n        }\n        For ($i = 0; $i -le  ($conffile.SourceFiles0.count - 1); $i++)\n        {\n            $private:addFile = $conffile.Strings.Item(&quot;FILE$i&quot;)\n   #&lt;doing some irrelevant stuff&gt;\n            try {\n                $private:zipfile.AddFile(&quot;$private:addFile&quot;)\n            } catch [Exception] {\n   #&lt;handling exception&gt;\n            }\n        }\n        try {\n            $private:sfxOptions = new-object Ionic.Zip.SelfExtractorSaveOptions\n        } catch [Exception] {\n   #&lt;handling exception&gt;\n        }\n        try {\n            $private:sfxOptions.Flavor = [Ionic.Zip.SelfExtractorFlavor]::WinFormsApplication\n        } catch [Exception] {\n   #&lt;handling exception&gt;\n        }\n        $private:sfxOptions.DefaultExtractDirectory = &quot;%USERPROFILE%\\AppData\\Local\\Temp\\&quot;\n        $private:sfxOptions.PostExtractCommandLine = $conffile.Strings.AppLaunched\n        $private:sfxOptions.SfxExeWindowTitle = $conffile.Strings.FriendlyName\n        $private:sfxOptions.RemoveUnpackedFilesAfterExecute = $true\n        $private:sfxOptions.Quiet = 1\n        $private:zipfile.CompressionLevel = 0\n        try {\n   #__this is where it gets stuck - not throwing any exception__\n            $private:zipfile.SaveSelfExtractor($conffile.Strings.TargetName, $private:sfxOptions)\n        } catch [Exception] {\n   #&lt;handling exception&gt;\n        }\n        try {\n            $private:zipfile.Dispose()\n        } catch [Exception] {\n   #&lt;handling exception&gt;\n        }</code></pre>\n\nWith correct input data this never throws an exception.<br />\nRunning this the first time <strong>always</strong> succeeds, but when running it again, there is a chance, that it will already get stuck at attempt 2. Most count of successful attempts I ran after each other were at a count of 4, I never created 5 times a successful SFX after each other.<br />\nMy repeating tests had <strong>always</strong> exactly the same input data and files.<br />\nAfter it gets stuck, I can kill the process to retry, but it will get stuck over and over until I restart the computer. The pretty strange thing is the sporadically stucking with a continuing stucking afterwards at something between 285MiB and 286MiB.<br />\n<br />\nMy idea already was some opened filehandle within the .dll but afaik that should get closed after killing a process.<br />\nI did not see any relevant errors by watching it with procmon.exe (Windows Tool: Process Monitor).<br />\n<br />\nCPU usage of powershell.exe is about 95% during the process, when it gets stuck it decreses to 0%.<br />\nMemory usage is about 700MiB with lots of free space left to use.<br />\nHDD I/O is on its limit while writing - which seems pretty normal when copying files.<br />\n<br />\nDo you have any ideas what could cause that problem?<br />\n<br />\nThank you in advance.<br />\nKind Regards.<br />\n",
    "PostedDate": "2013-12-04T06:57:56.5-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]