Search code examples
c++winapidllexewinsxs

Application unable to load Win32 assembly from WinSxS


I have a Win32 assembly (C++/CLI wrapper over my .NET code) which is supposed to be installed in WinSxS and should be referenced from that location by client applications using the API. I researched a bit on how to install a Win32 assembly in WinSxS and was finally able to get it done with the use of mainfest and catalog files.

The problem now is that I'm unable to use the assembly from a console app I've created for testing purposes. I added a <dependency> section to the exe manifest to reference the assembly (shown below) but it doesn't work.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <dependency>
    <dependentAssembly>
      <assemblyIdentity name="MyAssembly" processorArchitecture="x86" publicKeyToken="10f783dc6145a3s0" type="win32" version="1.0.0.58">
      </assemblyIdentity>
    </dependentAssembly>
  </dependency>
</assembly>

The exe fails with error message: The program can't start because MyAssembly.dll is missing from your computer. Try reinstalling the program to fix this problem.

On checking with Procmon, it appears that the exe is only searching for the dll in the exe location and all locations specified in the Path environment variable. When I placed the WinSxS location of the dll in Path variable and executed the app, it worked properly. I wonder if there is any other project setting that I'm missing when generating the exe manifest that's causing the issue. Ideas?


Solution

  • The issue turned out to be the UAC project setting. Setting the UAC property to No resolved the issue and application is now able to load the assembly without me having to use workarounds like adding to the PATH variable.