0

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.

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
user173399
  • 464
  • 5
  • 21
  • Is the signing certificate used for packages properly trusted on both machines? – Simon Mourier Apr 09 '22 at 17:57
  • Yes. Forgot to mention that. I installed the cert on the VM too so that the Appx install shows "trusted" and allows to install it. – user173399 Apr 10 '22 at 01:25
  • 1
    You could use Process Monitor tool from sysinternals to check what files are loaded or not. It could be a dependency dll that prevent the main one to be loaded. – Simon Mourier Apr 10 '22 at 06:26
  • Thanks, Simon. That put me on the right track and found dependence on 2 VC++ DLLs. But I haven't been able to use PackageDependency in app manifest to preinstall them. Updated the question accordiingly. – user173399 Apr 10 '22 at 11:41
  • It's possible you need the debug version of the VCLibs which are not downloaded automatically (need to be installed by hand), check this: https://learn.microsoft.com/en-us/troubleshoot/developer/visualstudio/cpp/libraries/c-runtime-packages-desktop-bridge and this https://stackoverflow.com/a/46118057/403671 – Simon Mourier Apr 10 '22 at 13:07
  • But I don't need to debug any more. I know that 2 VC++ DLLs are needed. However, just including a PackageDependency as described in the docs does not fix the App Installation. – user173399 Apr 10 '22 at 18:11
  • PackageDependency is not installing the required VC++ DLLs even when published to the store. I just did that test too. Where can we post such problems directly to Microsoft Support? Feedback hub doesn't work because it is not focused and not really visited by support folks. – user173399 Apr 14 '22 at 07:02
  • Don't know. It's probably some security issue. You can also install manually https://michlstechblog.info/blog/windows-download-appx-packages-from-microsoft-store-example-install-the-new-windows-terminal-offline/ – Simon Mourier Apr 14 '22 at 07:08
  • @SimonMourier Your initial tip on ProcessMonitor helped. I didn't use that but got the idea to use dependencies to find what is missing. If you can post it as a short answer, I can accept it and close this till I find more clues. Thanks. – user173399 Apr 14 '22 at 08:15
  • This was only a "generic" idea, not an answer. IMHO you should yourself with a bit more details about missing dependencies. – Simon Mourier Apr 14 '22 at 08:31

2 Answers2

1

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.

user173399
  • 464
  • 5
  • 21
0

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.

Sun Junwen
  • 1,068
  • 10
  • 20