I created a Shell Extension. It works correctly in Explorer, not so in Dopus

Without sharing too many details, I have created a Shell extension which shows a menu entry when one or multiple files of certain file extensions are selected.

The shell extension is built in C#, SharpShell, Net Framework 4.8.

The way it works is, if the user selects one or multiple files of certain extensions, the menu entry is shown. It's not shown if the user selects one or multiple files of other extensions.

This works perfectly in File Explorer.

In Directory Opus, however, it only shows the menu entry when ONE file is selected. When multiple files are selected it doesn't show.

I figure this is something I could fix on my end, either in the Dopus settings or changing something in the way SharpShell interacts with file selections - but some help from a Dopus developer or expert in this would be very appreciated.

So far I wasn't able to solve the problem.

You can attach a debugger (e.g. Visual Studio) to dopus.exe and set breakpoints on the code in your DLL which will let you see what's happening when Opus passes the list of files to you. That's probably the best place to start.

If you find something Explorer and Opus are doing differently, let us know.

I am probably missing something (I am not an expert obviously) but I fail at this approach simply because, when I select multiple files and right-click on them, the shell extension is not loaded by directory Opus at all. So the debugger doesn't see any interaction between the two. dopus only loads my dll when I right-click on a single file.

To clarify: the debugging works: The breakpoints are hit when I select and rightclick on one file in Dopus. Conversely, nothing happens when I select and right click on multiple files.

Windows Explorer, however, responds in both instances.
I think it might be a SharpShell-Dopus problem?

We'd need to know how the extension has been registered.

The extension is registered with Regasm. As I said, it has been working in Windows Explorer without problems.

Anyway, I think I have solved this, by adding this: [COMServerAssociation(AssociationType.AllFiles)]
next to this:
[COMServerAssociation(AssociationType.ClassOfExtension
in my main class, and some alchemy with conditions, when creating the menu entry.
Now it behaves correctly in Directory Opus as well.

So you had the extension registered for multiple file classes?

Did it only fail to work in Opus if files of different types were selected, or did it also fail with multiple files of the same class?

The shell extension has a list of valid file extensions (say for example .jpg, gif, png etc);
It should show its menu entry when one file with such file extensions is selected (jpg), many files of the same extension from the list (jpg, jpg, jpg) or many files with different extensions from the list (jpg, jpg, png, gif).
As I said this worked okay in Windows Explorer, but it failed the third case in Directory Opus, the shell extension would not be loaded at all if multiple files with valid extensions were selected.

EDIT: In some cases, it would fail to show even if multiple files of the same extensions were selected.

As I said it is solved now, but I had to add that line: [COMServerAssociation(AssociationType.AllFiles)], then check against it with something like this: bool hasInvalidFiles = SelectedItemPaths.Any(p => !_supportedExtensions.Contains(Path.GetExtension(p).ToLower()));
which may or may not be ideal :slight_smile:

Please understand I'm trying to get to the bottom of why it's not working in Opus.

Repeatedly saying it works in Explorer doesn't help with that. I believe you that it works in Explorer.

As soon as the thing is published on Github, I'll be happy to share it with you so you can look at the whole code. In the meantime feel free to ask anything specific that may help you address the problem. I probably cannot guess myself what info you may need. And rest assured I am a big fan of Directory Opus.

Please let us know when it's available and we'll take a look.

Hi. If you are still interested, my Shell Extension can be found here:

The file you should check is:

You may be able to build the shell extension with and without the line: [COMServerAssociation(AssociationType.AllFiles)]
and verify differences in behavior when selecting multiple ebooks.

Anything interesting you find out please let me know, could be there are improvements I can make on my end to solve this problem.