I 'am implementing an android app using Xamarin and MVVMCross. Inside my PCL I have a ZipUtility class and the following method:
public NoDataResponse UnCompressZipFile(string path, string filename)
{
NoDataResponse response = new NoDataResponse();
StringBuilder sb = new StringBuilder();
sb.AppendLine(string.Format("\r\nUnzipping '{0}' in '{1}' folder...", filename, path));
try
{
using (ZipArchive archive = ZipFile.Open(filename, ZipArchiveMode.Read))
{
foreach (System.IO.Compression.ZipArchiveEntry entry in archive.Entries)
{
if (entry.FullName.EndsWith(".txt", StringComparison.OrdinalIgnoreCase))
{
System.IO.Compression.ZipFile.ExtractToDirectory(filename, path);
break;
}
}
}
response.IsCallSuccessful = true;
sb.AppendLine(string.Format("\r\nFinished Unzipping file {0}.\r\n", filename));
response.BusinessEntityMessage = sb.ToString();
}
catch (Exception ex)
{
response.IsCallSuccessful = false;
response.BusinessEntityMessage = "\r\nUNZIPPING ERROR: " + ex.Message + "\r\n";
}
return response;
}
The ZipFile Class inside my method is part of the System.IO.Compression (System.IO.Compression.FileSystem namespace).
When I execute the method I get the following error:
System.InvalidProgramException: Invalid IL code in System.IO.Compression.ZipFile:Open (string,System.IO.Compression.ZipArchiveMode): method body is empty. at HHT.Core.Globals.ZipUtility.UnCompressZipFile (System.String path, System.String filename) [0x00033] in c:\Sandbox\HHT-ANDROID\HHTApp\HHT.Core\Globals\ZipUtility.cs:32
I'm not sure what is missing because the same code was working perfectly before inside the PCL.
I have also tried to run the same class using dependency injection (N=31 slodge) from my DROIDUI project and still get the same error.
I would appreciate any comments or ideas on this.