Skip to content

C++/CLI libraries may fail to load due to ijwhost.dll not being on the search path #38231

@elinor-fung

Description

@elinor-fung

To support C++/CLI libraries in .NET Core, ijwhost was created as a shim for finding and loading the runtime. All C++/CLI libraries are linked to this shim, such that ijwhost.dll is found/loaded when the C++/CLI library is loaded.

By default, Windows' DLL search will look for dependencies of a DLL as if they were loaded with just the module name. This means that, depending on how a host application loads the C++/CLI library, the C++/CLI library may fail to load due to ijwhost.dll not being found. In order for the load to work one of the following needs to be true:

  • ijwhost.dll is on the search path
  • the host applications specifies either LOAD_WITH_ALTERED_SEARCH_PATH or LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR flags for LoadLibrary such that dependencies are searched for in the same directory as the C++/CLI library

C++/CLI libraries cannot dictate how their hosts load them and authors should not need to be concerned with how the ijwhost shim is found and loaded. The runtime/tooling should make the usage of ijwhost hidden to the user such that it just works without user intervention.

In .NET Framework, the equivalent shim (mscoree/mscoreei) is system-wide, so this was not an issue.

Potential options:

  • Make ijwhost a static library that gets linked into the C++/CLI library
  • ?

@jkoritzinsky @AaronRobinsonMSFT @vitek-karas

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions