none
ZipFile method throws "Cannot load a reference assembly for execution" RRS feed

  • Question

  • Hi,

    I have a small WinForms application developed in C# for the .NET 4.5 framework. The app creates a bunch of files and then uses the ZipFile class in the System.IO.Compression namespace to compress the files into a ZIP file. This works fine on my development machine.

    However, when the App was delivered and installed on a different machine, it crashed. I realized it crashes when starting the compression task, so I added a try-catch block around the call to ZipFile.CreateFromDirectory(), and printed out the exception message. That exception was indeed thrown, and the message was "Cannot load a reference assembly for execution". 

    The installation is supposed to make sure the .NET 4.5 framework is on the target machine (that's a defined prerequisite). What could be causing this behavior? Is it a framework issue, or do I need to do something else to get it to work? Please help!

    Thanks,

    Yariv.

    Tuesday, September 23, 2014 7:19 AM

Answers

  • That code is in separate assembly (System.IO.Compression.FileSystem).  Verify the assembly is installed on the target machine.  If it isn't then verify the .NET 4.5 framework is actually installed.

    Michael Taylor
    http://blogs.msmvps.com/p3net

    Tuesday, September 23, 2014 5:34 PM
    Moderator