Shell 命名空间扩展无法在 Windows 7 中加载
我目前正在尝试创建自定义 Shell 命名空间扩展(用于呈现包含“子文件夹”和“文件”的虚拟文件夹,它们实际上是来自远程服务的分层树结构中的数据表示)。
该扩展是用 C# 编写的,我知道这曾经是一个坏主意,但自从 .NET 4 引入了不同版本的 .NET 运行时在同一进程中共存的可能性后,我认为这种限制不再存在一个问题。
到目前为止,通过遵循网络上提供的大量示例和参考资料,我已经让它在 Windows XP 中正常工作,但是当我在 Windows 7 中尝试它时(我还没有在 Vista 中尝试过,所以我不知道是否可以)它会在那里工作),扩展未加载。根据我的调试日志输出,它注册得很好,但是当我打开 Windows 资源管理器窗口时,似乎没有发生对 COM 接口的常见调用(通常以 IPersistFolder::Initialize 开头)。事实上,甚至没有调用类构造函数。我不知道是否正在查询接口(成功与否),因为我不确定如何在 .NET 中检测到该接口,以便我可以记录它。所以,基本上,我没有任何线索可以参考,因为甚至在我有机会记录有关可能出现问题的任何有用信息之前它就失败了。
有谁知道问题可能是什么?在处理 shell 命名空间扩展时,与 Windows XP 相比,Windows 7 是否有任何我应该注意的特性需要考虑?如果需要更多详细信息,请随时询问(我试图保持简短,因为我确信没有人会欣赏我在此处复制并粘贴我的整个代码,并且我无法将其缩减为仅相关部分,因为我只是不知道这些是什么......)
I'm currently trying to create a custom Shell Namespace Extension (for presenting a virtual folder containing "subfolders" and "files", which are actually the representation of data in a hierarchical tree structure from a remote service).
The extension is written C#, which - I'm aware - used to be a bad idea, but ever since .NET 4 introduced the possibility of different versions of the .NET runtime coexisting within the same process, I figured this limitation was no longer an issue.
So far I've gotten it to work fine in Windows XP by following the plenty examples and references available on the web, but when I try it in Windows 7 (I have not tried it in Vista yet, so I don't know whether it would work there), the extension is not loaded. According to my debug log output, it registers fine, but when I open a Windows Explorer window, none of the usual calls to the COM interfaces seem to occur (usually starting with IPersistFolder::Initialize). In fact, not even the class constructor is being called. I do not know whether the interfaces are being queried for (successfully or not) because I'm not sure how to detect that in .NET so I can log it. So, basically, I don't have any clues to go by, because it fails even before I get the chance to record any useful info about what might be going wrong.
Does anyone happen to have any idea what the problem might be? Are there any peculiarities in Windows 7 as opposed to Windows XP that need to be taken into account when dealing with shell namespace extensions that I should be aware of? If more details are required, feel free to ask (I tried to keep it brief, because I'm sure noone would appreciate me copy&pasting my entire code here, and I couldn't cut it down to just the relevant parts because I simply don't know which ones these are...)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我刚才遇到了一个非常相似的情况:
我使用的是 ATL 和 64 位,所以我知道 .NET 不是我的问题。
事实证明,问题是我在注册表中没有以下值:
[HKEY_CLASSES_ROOT\CLSID\{您的 CLSID}\ShellFolder]
"Attributes"=dword:20000000
(仅存在键或值是不够的 - 您需要(至少)具有此特定属性值才能开始操作)。
添加后,您需要终止所有 explorer.exe 进程并重新启动(例如使用任务管理器)。我希望这也能解决您的问题。
I had a very similar case just now:
I was using ATL and 64bit, so I knew .NET was not my problem.
Turns out the problem was I didn't have the following value in the registry:
[HKEY_CLASSES_ROOT\CLSID\{your CLSID}\ShellFolder]
"Attributes"=dword:20000000
(It's not enough to have the key or value exist - you need to have (at least) this specific attribute value to get something started).
After you add it, you need to kill all explorer.exe processes and start one again (e.g. using task manager). I hope this solves your problem too.
可能是由于以下原因造成的:
您的命名空间是否有任何可能无法加载的依赖项?
注册成功了吗?您是否确实检查过注册表是否创建了正确的条目?请记住,如果 UAC 已打开,您可能需要提升权限。
作为自己开发如此复杂的野兽的替代方案,请考虑使用 EZNamespaceExtensions - 它使它变得非常简单您可以专注于提供特定于您的 nse 的功能。
免责声明:我们是 EZNamespaceExtensions 的开发人员。
It can be due to following reasons:
Does your namespace have any dependencies that may fail to load?
Did the registration occur successfully? Did you actually check the registry if proper entries are created? Remember that if UAC is on you may need elevated privileges.
As an alternative to developing such complicated beasts yourself, consider using EZNamespaceExtensions - it makes it very easy and you can focus on providing your nse-specific functionality.
DISCLAIMER: We are the developers of EZNamespaceExtensions.
谢谢@Oren,对我来说问题是我需要删除以下注册表项中的所有其他版本:
HKEY_CLASSES_ROOT\CLSID{your CLSID}\InprocServer32\
我只保留了当前版本。我认为问题在于我的版本号高于当前版本。
添加;我必须对另一台有类似问题的计算机执行相同的操作,甚至更多操作。
我从 HKEY_LOCAL_MACHINE\SOFTWARE\CLASSES\CLSID{your CLSID}\InprocServer32\ 中删除了所有其他版本
Thanks @Oren, for me the issue was that I needed to remove all other versions in the following regedit entry:
HKEY_CLASSES_ROOT\CLSID{your CLSID}\InprocServer32\
I only left the current version. I think the issue was that I had a version number that was higher than my current version.
To add; I had to do the same and more to another computer which was having a similar issue.
I removed all other versions from HKEY_LOCAL_MACHINE\SOFTWARE\CLASSES\CLSID{your CLSID}\InprocServer32\