【发布时间】:2014-01-16 15:37:02
【问题描述】:
我正在使用 Xamarin 和 MVVMCross 实现一个 android 应用程序。在我的 PCL 中,我有一个 ZipUtility 类和以下方法:
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;
}
我方法中的 ZipFile 类是 System.IO.Compression(System.IO.Compression.FileSystem 命名空间)的一部分。
当我执行该方法时,我收到以下错误:
System.InvalidProgramException:System.IO.Compression.ZipFile 中的 IL 代码无效:Open (string,System.IO.Compression.ZipArchiveMode):方法体为空。 在 C:\Sandbox\HHT-ANDROID\HHTApp\HHT.Core\Globals\ZipUtility.cs:32 中的 HHT.Core.Globals.ZipUtility.UnCompressZipFile(System.String 路径,System.String 文件名)[0x00033] >
我不确定缺少什么,因为之前在 PCL 中相同的代码运行良好。
我还尝试使用我的 DROIDUI 项目中的依赖注入 (N=31 slodge) 运行相同的类,但仍然遇到相同的错误。
我将不胜感激任何关于此的 cmets 或想法。
【问题讨论】:
标签: c# xamarin.android xamarin mvvmcross portable-class-library