c++ - Error while installing context menu based on IExplorerCommand - Stack Overflow

I am trying to install a context menu handler written in C++ that implements IExplorerCommand. For inst

I am trying to install a context menu handler written in C++ that implements IExplorerCommand. For installation, I use the instructions which are specified in this repository:

Everything is going well, except for the last step. When I run the application which should install the msix package, the manifest of which contains information about the context menu, I get the following error:

A fatal error occurred. The required library hostfxr.dll could not be found. If this is a self-contained application, that library should exist in [C:\Users\Username\Desktop\windows-menu\bin]. If this is a framework-dependent application, install the runtime in the global location [C:\Program Files\dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x64\InstallLocation].

Why does this error occur, and how can I fix it? I am using Windows 10.


UPDATE

I copied the hostfxr.dll file to the bin folder, but after that I got the following output:

Architecture: x64 Framework: 'Microsoft.NETCore.App', version '3.1.0' (x64) .NET location: C:\Users\Username\Desktop\windows-menu\bin\ No frameworks were found.

Does installing a context menu really require .NET? What if my program is used by a user who does not have .NET on their computer?

I am trying to install a context menu handler written in C++ that implements IExplorerCommand. For installation, I use the instructions which are specified in this repository:

https://github/microsoft/AppModelSamples/tree/master/Samples/SparsePackages

Everything is going well, except for the last step. When I run the application which should install the msix package, the manifest of which contains information about the context menu, I get the following error:

A fatal error occurred. The required library hostfxr.dll could not be found. If this is a self-contained application, that library should exist in [C:\Users\Username\Desktop\windows-menu\bin]. If this is a framework-dependent application, install the runtime in the global location [C:\Program Files\dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x64\InstallLocation].

Why does this error occur, and how can I fix it? I am using Windows 10.


UPDATE

I copied the hostfxr.dll file to the bin folder, but after that I got the following output:

Architecture: x64 Framework: 'Microsoft.NETCore.App', version '3.1.0' (x64) .NET location: C:\Users\Username\Desktop\windows-menu\bin\ No frameworks were found.

Does installing a context menu really require .NET? What if my program is used by a user who does not have .NET on their computer?

Share Improve this question edited Mar 22 at 17:59 Remy Lebeau 601k36 gold badges507 silver badges851 bronze badges asked Mar 22 at 14:57 Joe JJoe J 4839 bronze badges 35
  • 2 The program that you're running requires .NET Core (3.1 it seems, the one in the sample is .NET Framework 4.6.1), but, no, a context menu doesn't requires .NET at all. – Simon Mourier Commented Mar 22 at 15:37
  • @SimonMourier The program that runs PackageManager to install the context menu is written in C#. Do you mean that this happens because of this fact? If, say, the same program were written in C++, this error would not have occurred? – Joe J Commented Mar 22 at 15:39
  • @SimonMourier After installing .NET, this error disappeared. PackageManager installed the menu successfully, but the menu itself does not show when I right-click on a file. Should IExplorerCommand show up under Windows 10 or does its menu only show up under Windows 11? – Joe J Commented Mar 22 at 15:55
  • @SimonMourier At the moment I have no idea how to debug this. The only thing I managed to find out is the fact that the dll itself is not even loaded by File Explorer. I realized this when I tried to rename the dll. Usually after loading the dll, File Explorer does not allow you to delete/rename the context menu dll file, but in this case it was possible to rename/delete the dll. I use this example: github/xandfis/W11ContextMenuDemo/tree/master even DllGetActivationFactory and DllGetClassObject does not calling – Joe J Commented Mar 22 at 16:45
  • for check are all loaded in process, need do this direct, not try delete file (rename is possible even for loaded dll). and usually this dll must create log, and log all operations, load, unload, class object reate request, inteface calls. etc. how minimum until you debug/design this – RbMm Commented Mar 22 at 17:18
 |  Show 30 more comments

1 Answer 1

Reset to default 0

Because the context menu installer is written in C#, .NET components must be installed for the program to run.

In addition, if installing on a fresh machine, the Microsoft Visual C++ Redistributable must be installed to provide the C++ (MSVC) runtime libraries.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744310912a4567942.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信