TypeInitializationException appears in Silverlight 5 OOB (Out Of Browser)

Aug 17, 2011 at 9:12 AM

Hello,

I'm a fan of DotNetZip, so now I move my application to Silverlight 5 (beta) OOB (SL5 OOB unrestricted access local file system)

I have use Ionic.Zip for Silverlight (version 1.9.1.8)

Here's my code:

if (Application.Current.HasElevatedPermissions)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Multiselect = false;

                if (ofd.ShowDialog() == true)
                {
                    string zipFilePath = ofd.File.FullName;

                    Stream stream = ofd.File.OpenRead();

                    ZipFile zip = ZipFile.Read(stream);

                    zip.Password = "samplepassword";

                    zip.ExtractAll("D:\tmp");
                }
            }

 

The error appears at "ZipFile zip = ZipFile.Read(stream)", the same error when I replace stream with file path of my zip file

TypeInitializationException was unhandled by user code

[TypeInitialization_Type] 

Arguments: Ionic.Zip.ZipFile



Could you post the example how to use in Silverlight OOB? Thank you so much.