我有一个使用图标处理器的SharpShell的项目。它可以窥视APK内部,以便找到并显示它们的图标。我已经让它工作了,但也有一些副作用。如果我尝试将APK重命名为其他名称,比如从A.apk重命名为B.apk,那么资源管理器就会崩溃,并且我找不到原因。
以下是主要部分和日志记录部分:
using System;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using ApkDetails;
using SharpShell.Attributes;
using SharpShell.SharpIconHandler;
namespace ApkIconHandler {
[ComVisible(true)]
[COMServerAssociation(AssociationType.ClassOfExtension, ".apk")]
public class ApkHandler : SharpIconHandler {
protected override Icon GetIcon(bool smallIcon, uint iconSize) {
try {
APK apk = new APK(SelectedItemPath);
using (Bitmap icon = apk.GetIcon()) {
IntPtr icH = icon.GetHicon();
Icon ico = Icon.FromHandle(icH);
return ico;
}
} catch (Exception ex) {
File.AppendAllText(@"C:\APKError.txt", ex.Message + Environment.NewLine + ex.StackTrace);
return Icons.DefaultIcon;
}
}
protected override void LogError(string message, Exception exception = null) {
base.LogError(message, exception);
String err = message;
if (exception != null) err += Environment.NewLine + exception.StackTrace;
File.AppendAllText(@"C:\APKError.txt", err + Environment.NewLine);
}
protected override void Log(string message) {
base.Log(message);
File.AppendAllText(@"C:\APKLog.txt", message + Environment.NewLine);
}
}
}我的APK代码运行aapt d badging "path.apk"并解析输出以获取图标信息,GetIcon以压缩形式打开APK以获取该文件。我将所有这些都包装在一个try/catch中,并绑定到SharpShell的LogError方法中,但我从未得到任何输出。我禁用了UAC。我不认为在写入驱动器根目录时存在权限问题,因为APKLog.txt确实出现了,但没有提供有用的信息。
我看到"Windows资源管理器已停止工作“窗口,它将此信息列为”问题签名“。
Problem Event Name: CLR20r3
Problem Signature 01: explorer.exe
Problem Signature 02: 6.1.7601.17567
Problem Signature 03: 4d672ee4
Problem Signature 04: mscorlib
Problem Signature 05: 4.0.30319.18047
Problem Signature 06: 5155314f
Problem Signature 07: 326
Problem Signature 08: 5d
Problem Signature 09: System.AccessViolationException
OS Version: 6.1.7601.2.1.0.256.48
Locale ID: 1033
Additional Information 1: 59cf
Additional Information 2: 59cf5fdf81b829ceb8b613f1f092df60
Additional Information 3: 6d90
Additional Information 4: 6d903bfb0ab1d4b858654f0b33b94d7f我看到它显示为System.AccessViolationException,但我的代码都没有捕捉到它。有没有人能提供一点关于这里发生的事情的见解?
发布于 2013-08-16 03:52:20
我可以建议您确保在调试模式下构建服务器,然后从sharpshell运行“服务器管理器”工具吗?完成后,从tools菜单启用日志记录。从现在开始,只要sharpshell代码捕获到您的代码可能抛出的异常,它就会将其记录到事件日志中。
您可以在自己的SharpShell服务器中使用LogMessage和LogError将消息或错误写入事件日志,这将使诊断发生了什么变得更容易!
https://stackoverflow.com/questions/16965912
复制相似问题