Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shell Namespace Extension fails to load in 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...)

like image 587
Andreas Baus Avatar asked Oct 11 '22 13:10

Andreas Baus


1 Answers

I had a very similar case just now:

  • I saw my shell extension in the right location (in my case "My Computer"), icon and all.
  • Still, no instantiation was done on my COM class (I checked process monitor), and no call to IPersistFolder::Initialize.

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.

like image 139
Oren Avatar answered Dec 31 '22 06:12

Oren