Shell extension DLL in a packaged win32 desktop app not working on some systems

442 views Asked by At

Reference: Integrate a packaged desktop app with File Explorer https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/integrate-packaged-app-with-file-explorer

I'm using the sample code similar to the github repo referred to in the above article to get my own context menu item and action when any folder is right-clicked. https://github.com/microsoft/Windows-AppConsult-Samples-DesktopBridge/tree/main/Docs-ContextMenuSample

This works well on my laptop using Windows 11. However, the same app when installed on another copy of Windows 11 in a Hyper-V machine does not work. Both Windows systems are updated to the same build. Same AppX is being installed on both systems where it works on one but does not work on another.

I put debug logging in the DLL and found that DLLMain is called when I right-click a folder in the Running system. Whereas even the DLLMain is not called on the faulty system. This means the DLL is not registered on that system when installing the Appx. Exactly same situation is happening on a Windows 10 system which is a hyper-v VM.

Question: Is there some kind of setting that prevents registering Context Menu Dlls from packaged apps? Only that would explain working on one system and not working on another.

Another idea is to see event viewer for log. But where to look?

Update: Finally found that it needs the following DLLs: VCRUNTIME140.dll and VCRUNTIME140_1.dll.

This means it needs some package dependency to get the above DLLs. Tried the following:

Added PackageDependency in appx manifest:

<PackageDependency Name="Microsoft.VCLibs.140.00.UWPDesktop" MinVersion="14.0.24217.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />  

But it doesn't really solve the problem.

2

There are 2 answers

0
user173399 On BEST ANSWER

Finally, it turned out that I was using ProcessorArchitecture in Appx as x86 but the shell dll was required to be X64. I changed ProcessorArchitecture to x64 and it started working.

0
Sun Junwen On

If you follow these samples: https://github.com/microsoft/Windows-AppConsult-Samples-DesktopBridge/tree/main/Docs-ContextMenuSample and https://github.com/microsoft/Windows-classic-samples/tree/main/Samples/Win7Samples/winui/shell/appshellintegration/ExplorerCommandVerb with using Visual Studio 2019/2022, you need to make sure that Dll.def is set as "ModuleDefinitionFile" in linker in Release mode.

The vcxproj file in these samples has wrong configuration in Release. And the dll build in Release is not able to run by dllhost.