2

Raymond Chen said in 2006 and repeated in 2013:

Do not write in-process shell extensions in managed code

But I am perplex since there even is a library which is exclusively dedicated to writing shell extensions in C# (called SharpShell).

I am actually using this library in my software (for context menus and icon overlays). It is very convenient, but since reading the article above I am starting to wonder whether I should pull back from C# for shell extensions (all other parts of my software are in C#).

QUESTION: So, should managed code shell extensions be avoided at all costs?
Or are there precautions (maybe implemented inside SharpShell?) that can actually make it safe? If not 100% safe, what are the main risks?
I am a Linux/Java person so I might be unaware of Windows things that seem obvious to others.

  • 3
    This MSDN article does a better job of giving an overview of the risks involved. – rwong Feb 19 '16 at 12:31
  • Just curious (since you said you were unaware of Windows things) - were you familiar with: (1) reference-counting (2) Microsoft COM (Component Object Model) programming (3) IDisposable.Dispose in C# (4) debugging C# code that contains some reference-counting bugs in the sense that it was not using the C# COM wrappers correctly. These are the competency prerequisites before one could even consider developing in COM and/or C# frameworks that require guaranteed object release. Note that object release is different from (unrelated to) garbage collection. – rwong Feb 19 '16 at 13:12
  • In some COM use cases, there are situations where the order of two object releases are critical - if two objects are released in the wrong order it could result in catastrophic failures. Such is the reality in COM programming, even if you would like to harshly criticize it for allowing this to happen. – rwong Feb 19 '16 at 13:15
  • @rwong: Would you mind adding an answer about that, including how SharpShell manages to avoid that (or not)? (1) Some kind of garbage collection I guess? (2, 3, 4) No, sorry, none of the shell extension tutorials I followed mentioned this, but if you write an answer be sure to mention this so that people like me can look it up, thanks! – Nicolas Raoul Feb 20 '16 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.