SOLVED

MSIX: How to handle Context menu in notepad ++ application?

%3CLINGO-SUB%20id%3D%22lingo-sub-2606599%22%20slang%3D%22en-US%22%3EMSIX%3A%20How%20to%20handle%20Context%20menu%20in%20notepad%20%2B%2B%20application%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2606599%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Team%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECould%20you%20please%20help%20us%20in%20handling%20Context%20Menu%20in%20the%20MSIX%20notepad%20%2B%2B%20application%3F%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20per%20our%20understanding%2C%20MSIX%20is%20not%20supporting%20the%20full%20functionality%20of%20the%20Context%20Menu.%3C%2FP%3E%3CP%3EBut%20how%20can%20we%20achieve%20the%20same%20though%20file%20association.%26nbsp%3B%20If%20possible%20kindly%20provide%20us%20sample%20Manifest.xml%20file.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2677777%22%20slang%3D%22en-US%22%3ERe%3A%20MSIX%3A%20How%20to%20handle%20Context%20menu%20in%20notepad%20%2B%2B%20application%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2677777%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F787767%22%20target%3D%22_blank%22%3E%40shreedhar_ghare%3C%2FA%3E%26nbsp%3Blegacy%20IContextMenu%20context%20menu%20support%20is%20now%20available%20in%20insider%20builds%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmsix%2Fpackaging-tool%2Fsupport-legacy-context-menus%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESupport%20legacy%20context%20menus%20-%20MSIX%20%7C%20Microsoft%20Docs%3C%2FA%3E)%20This%20feature%20is%20not%20in%20retail%20builds%20yet.%3C%2FP%3E%0A%3CP%3EPlease%20let%20us%20know%20if%20you%20have%20follow%20up%20questions.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2679804%22%20slang%3D%22en-US%22%3ERe%3A%20MSIX%3A%20How%20to%20handle%20Context%20menu%20in%20notepad%20%2B%2B%20application%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2679804%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F787767%22%20target%3D%22_blank%22%3E%40shreedhar_ghare%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EAlthough%20Microsoft%20has%20added%20support%20in%20the%20insider%20build%20of%20the%20MSIX%20Packaging%20Tool%2C%20you%20are%20likely%20to%20find%20that%20that%20the%20context%20menu%20for%20that%20particular%20app%20will%20not%20work.%20The%20issue%20is%20that%20the%20COM%20based%20shell%20extension%20runs%20in-process%20in%20the%20explorer%20process%20and%20does%20not%20have%20access%20to%20the%20package%20app%20registry%20in%20the%20container.%20Most%20context%20menus%20don't%20need%20access%20to%20the%20registry%20and%20work%20just%20fine%2C%20but%20that%20one%20does.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%20is%20odd%20because%20it%20always%20adds%20the%20same%20menu%20item%20anyway%3B%20it%20isn't%20contextual.%26nbsp%3B%20Some%20have%20solved%20this%20in%20this%20app%20by%20adding%20a%20traditional%20file%20association%20with%20a%20static%20shell%20verb%20instead.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2685434%22%20slang%3D%22en-US%22%3ERe%3A%20MSIX%3A%20How%20to%20handle%20Context%20menu%20in%20notepad%20%2B%2B%20application%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2685434%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F146612%22%20target%3D%22_blank%22%3E%40TIMOTHY%20MANGAN%3C%2FA%3E%26nbsp%3Bcontext%20menus%20work%20for%20Notepad%2B%2B%20when%20packaged.%20Try%20adding%20this%20to%20the%20app%20manifest%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3Exmlns%3Adesktop9%3D%22http%3A%2F%2Fschemas.microsoft.com%2Fappx%2Fmanifest%2Fdesktop%2Fwindows10%2F9%22%3CBR%20%2F%3Exmlns%3Acom%3D%22http%3A%2F%2Fschemas.microsoft.com%2Fappx%2Fmanifest%2Fcom%2Fwindows10%22%3C%2FPRE%3E%0A%3CPRE%3E%3CDEPENDENCIES%3E%3CBR%20%2F%3E%3CTARGETDEVICEFAMILY%20name%3D%22Windows.Desktop%22%20minversion%3D%2210.0.17763.0%22%20maxversiontested%3D%2210.0.21301.0%22%3E%3C%2FTARGETDEVICEFAMILY%3E%3CBR%20%2F%3E%26lt%3B%2FDependencies%26gt%3B%3C%2FDEPENDENCIES%3E%3C%2FPRE%3E%0A%3CPRE%3E%3CEXTENSIONS%3E%3CBR%20%2F%3E%3CEXTENSION%20category%3D%22windows.comServer%22%3E%3CBR%20%2F%3E%3CCOMSERVER%3E%3CBR%20%2F%3E%3CSURROGATESERVER%20displayname%3D%22Notepad%2B%2B%20Shell%20Extensions%22%3E%3CBR%20%2F%3E%3CCLASS%20id%3D%22B298D29A-A6ED-11DE-BA8C-A68E55D89593%22%20path%3D%22VFS%5CProgramFilesX64%5CNotepad%2B%2B%5CNppShell_06.dll%22%20threadingmodel%3D%22STA%22%3E%3C%2FCLASS%3E%3CBR%20%2F%3E%3C%2FSURROGATESERVER%3E%3CBR%20%2F%3E%3C%2FCOMSERVER%3E%3CBR%20%2F%3E%3C%2FEXTENSION%3E%3CBR%20%2F%3E%3CEXTENSION%20category%3D%22windows.fileExplorerClassicContextMenuHandler%22%3E%3CBR%20%2F%3E%3CFILEEXPLORERCLASSICCONTEXTMENUHANDLER%3E%3CBR%20%2F%3E%3CEXTENSIONHANDLER%20type%3D%22*%22%20clsid%3D%22B298D29A-A6ED-11DE-BA8C-A68E55D89593%22%3E%3C%2FEXTENSIONHANDLER%3E%3CBR%20%2F%3E%3C%2FFILEEXPLORERCLASSICCONTEXTMENUHANDLER%3E%3CBR%20%2F%3E%3C%2FEXTENSION%3E%3CBR%20%2F%3E%26lt%3B%2FExtensions%26gt%3B%3C%2FEXTENSIONS%3E%3C%2FPRE%3E%0A%3CP%3EWhen%20you%26nbsp%3Bspecify%20to%20use%20this%20new%20surrogate%20server%20in%20the%20appxmanifest%2C%20Shell%20creates%20the%20surrogate%20server%20out-of-proc%20and%20this%20server%20will%20handle%20creating%20custom%20IContextMenu%20COM%20object%20and%20handle%20data%20marshalling.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello Team,

 

Could you please help us in handling Context Menu in the MSIX notepad ++ application? 

As per our understanding, MSIX is not supporting the full functionality of the Context Menu.

But how can we achieve the same though file association.  If possible kindly provide us sample Manifest.xml file. 

 

3 Replies

@shreedhar_ghare legacy IContextMenu context menu support is now available in insider builds (Support legacy context menus - MSIX | Microsoft Docs) This feature is not in retail builds yet.

Please let us know if you have follow up questions.

@shreedhar_ghare

Although Microsoft has added support in the insider build of the MSIX Packaging Tool, you are likely to find that that the context menu for that particular app will not work. The issue is that the COM based shell extension runs in-process in the explorer process and does not have access to the package app registry in the container. Most context menus don't need access to the registry and work just fine, but that one does.

 

It is odd because it always adds the same menu item anyway; it isn't contextual.  Some have solved this in this app by adding a traditional file association with a static shell verb instead.

best response confirmed by shreedhar_ghare (Occasional Contributor)
Solution

@TIMOTHY MANGAN context menus work for Notepad++ when packaged. Try adding this to the app manifest:

 

xmlns:desktop9="http://schemas.microsoft.com/appx/manifest/desktop/windows10/9"
xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.21301.0" />
</Dependencies>
<Extensions>
<com:Extension Category="windows.comServer">
<com:ComServer>
<com:SurrogateServer DisplayName="Notepad++ Shell Extensions">
<com:Class Id="B298D29A-A6ED-11DE-BA8C-A68E55D89593" Path="VFS\ProgramFilesX64\Notepad++\NppShell_06.dll" ThreadingModel="STA" />
</com:SurrogateServer>
</com:ComServer>
</com:Extension>
<desktop9:Extension Category="windows.fileExplorerClassicContextMenuHandler">
<desktop9:FileExplorerClassicContextMenuHandler>
<desktop9:ExtensionHandler Type="*" Clsid="B298D29A-A6ED-11DE-BA8C-A68E55D89593" />
</desktop9:FileExplorerClassicContextMenuHandler>
</desktop9:Extension>
</Extensions>

When you specify to use this new surrogate server in the appxmanifest, Shell creates the surrogate server out-of-proc and this server will handle creating custom IContextMenu COM object and handle data marshalling.