self extractor problem in 1.8 release

Jul 3, 2009 at 12:06 AM

I've tried both modes for creating a self extractor for a strongly encrypted (AES128/256) password protected zip. It creates the file which appears to be a reasonable size. However the file throws errors when I try to execute it. Has anyone else seen this?  I'm developing a web application. Creating a standard zip file seems to work just fine.  I've tried a number of other packages (sharp/7-zip) but none compare to this one in terms of shear ease of use/ intelligence of design. I'm sure I'm missing something simple. Any help would be appreciated.

Here is the error

Microsoft Windows XP [Version 5.1.2600]

Exception while extracting: System.IO.FileLoadException: Could not load file or
assembly 'Ionic.Zip, Version=1.8.4.2, Culture=neutral, PublicKeyToken=edbe51ad94
2a3f5c' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x8
0004003 (E_POINTER))
File name: 'Ionic.Zip, Version=1.8.4.2, Culture=neutral, PublicKeyToken=edbe51ad
942a3f5c' ---> System.NullReferenceException: Object reference not set to an ins
tance of an object.
   at Ionic.Zip.SelfExtractor.Resolver(Object sender, ResolveEventArgs args)
   at System.AppDomain.OnAssemblyResolveEvent(String assemblyFullName)
   at Ionic.Zip.SelfExtractor.Run()
   at Ionic.Zip.SelfExtractor.Main(String[] args)



And here is the code that produced it
            using (ZipFile zip = new ZipFile())
            {
                zip.Password = thePassword.Trim();
                zip.Encryption = EncryptionAlgorithm.WinZipAes128;
                zip.AddDirectory(inputFolderPath);
                //zip.Save(outputFilePath);
                zip.SaveSelfExtractor(outputFilePath, SelfExtractorFlavor.ConsoleApplication);
            }
Coordinator
Jul 3, 2009 at 2:48 AM

Hmm, that's very odd.

You're seeing a loader error.  When you call SaveSelfExtractor(), DotNetZip embeds the Ionic.Zip.dll into the executable.  When you run the SFX, the exe unpacks the DLL from within *itself*, and then calls into that DLL.  It sounds tricky but it's really just a packing convenience.  It's not reasonable to have to distribute the DLL with every SFX.

The error you are seeing is a null pointer exception in the assembly resolver method. In other words, The SFX is having trouble finding and extracting the DLL which is embedded within itself.   I'm trying to imagine how that might happen, and I just can't come up with any good ideas.

Are you doing anything unusual with the EXE?  Running it from a network share?  Modifying it after it is built?  Renaming it?  I'm trying to think what would lead to this kind of problem.

I have this exact scenario in the set of tests that I run every time I cut a release.   (The tests succeed)

  I'll wait for you to get back to me, in the meantime I will think some more about it.

 

Coordinator
Jul 3, 2009 at 2:50 AM

Do you work in an enterprise where they have modified the machine.config for managed machines?  Not sure, but It may be possible to disable the loading of assemblies the way I have done it in the SFX, via an enteprise policy.  Could that be a possibility?

Jul 3, 2009 at 4:19 AM

Since I'm working in ASP.Net, I am using the debug version of the Ionic.Zip.ddl. I imagine that its offsets may be different. Could this be the problem??

I have full control of my machine.config and it is totally untweaked. So I doubt that is it.

Coordinator
Jul 3, 2009 at 4:56 AM

Nope.  I don't think it's offsets.

What do you mean "since you're working in ASP.NET, you're using the debug version of the DLL."  Are the two things related in some way I don't understand?  What does ASP.NET have to do with whether you use the debug version versus the Release version?  It doesn't matter for the purposes of this puzzle, but I wanna make sure I understand what you're doing.

Can you try to run the fusion log viewer to help diagnose this failure?  The instructions are here:  http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx 

At the same time I'm putting together a version of the library that I hope will produce a more informative error message when the failure occurs.  It will be v1.8.4.4.  you will be able to download it soon.

 

Coordinator
Jul 3, 2009 at 6:30 AM

ok, v1.8.4.4 is up, available for you to try.

Jul 3, 2009 at 6:33 PM

Thanks for uploading the new version.

I'm sorry my earlier message wasn't particularly clear. What I meant to say is that I'm writing this code as an ASP.Net application that will reside locally. In these cases, I generally don't bother with the release version and only drag & drop the debug versions over to my Visual Studio 2005 project window (one full set in the bin directory and one full set in the project directory).

I've tried the new code and this is the error message that it produces:

C:\Test>test_7e4b2440-2.exe
Exception while extracting: System.IO.FileLoadException: Could not load file or
assembly 'Ionic.Zip, Version=1.8.4.4, Culture=neutral, PublicKeyToken=edbe51ad94
2a3f5c' or one of its dependencies. General Exception (Exception from HRESULT: 0
x80131500)
File name: 'Ionic.Zip, Version=1.8.4.4, Culture=neutral, PublicKeyToken=edbe51ad
942a3f5c' ---> System.Exception: GetManifestResourceStream returns null. Availab
le resources: [Ionic.Zip.DLL]
   at Ionic.Zip.SelfExtractor.Resolver(Object sender, ResolveEventArgs args)
   at System.AppDomain.OnAssemblyResolveEvent(String assemblyFullName)
   at Ionic.Zip.SelfExtractor.Run()
   at Ionic.Zip.SelfExtractor.Main(String[] args)

C:\Test>
I can't see where this would matter, but here is how I am defining the output path for the 
        string filename = ZipFilenameTextBox.Text.Trim().Replace(" ", "_");
        int dot = filename.IndexOf(".");
        if (dot > 1) filename = filename.Remove(dot);
        filename = filename + "_" + Session["Guid"].ToString().Trim() + ".exe";
        string outputFilePath = @"\\server14\filestore_data\" + filename;
I'll try the fusion log next. Thanks again for your help. -pb
Coordinator
Jul 3, 2009 at 7:20 PM

PB, I have the answer. 

The problem is that the self-extractor is looking for an embedded assembly named "Ionic.Zip.dll".  What it has found instead is an embedded assembly named "Ionic.Zip.DLL".  The case of the extension is different.  And so it fails. 

I think you may be able to fix this in your setup by renaming the assembly to Ionic.Zip.dll, rather than Ionic.Zip.DLL, in your ASP.NET bin directory.   Just to be clear, it is the name of the DLL that is used when the self-extractor is being built, not the name of the DLL when the SFX is being run.  It really should not matter, but the self-extractor code is currently sensitive to the case mismatch.

The permanent fix for this is to allow a match even when the case of the extension is different (dll versus DLL versus Dll etc). 

I'll submit a fixed assembly shortly. 

Coordinator
Jul 3, 2009 at 7:27 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Jul 3, 2009 at 10:00 PM

If you grab release v1.8.4.5, it should work for you (whether or not you rename the DLL).