0

I've followed Microsoft's docs about manifests and wanted to use one in my application https://learn.microsoft.com/en-us/cpp/build/how-to-embed-a-manifest-inside-a-c-cpp-application?view=msvc-170

I'm using CMake as my build system for a graphics engine, I have a target A linking my assembly manifest, let's call it test.manifest(and a dynamic library Test_debug) specified in sources list when creating this target (CMake allows to handle any *.manifest files this way)

add_executable(A main.cpp <path>/test.manifest)

the test.manifest looks following

<assembly manifestVersion="1.0">
  <assemblyIdentity type="Win32" name="MyCompany.Windows.Test" version="1.0.0.0" publicKeyToken="0000000000000000" />
  <file name="Test_debug.dll"/>
</assembly>

my target A needs to load the Test_debug.dll and this library should be located given assembly directory thanks to application assembly manifest

the Test_debug.dll is located at path x/y/z/Test_debug.dll, the assembly manifest is located at x/y/z/test.manifest/test.manifest

my target A that links imported library Test_debug.lib therefore needs Test_debug.dll has following pragma in it's source cpp code

#pragma comment(linker, "/manifestdependency:\"name='MyCompany.Windows.Test' "\
                        "version='1.0.0.0' "\
                        "type='Win32'\"")

but for some reason when I try to launch target A executable I get this message from Event Viewer

Activation context generation failed for "an_absolute_path\bin\A.exe". Dependent Assembly MyCompany.Windows.Test,type="Win32",version="1.0.0.0" could not be found. Please use sxstrace.exe for detailed diagnosis.

and this when it tries to execute A exe

The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail

if I get this correctly having my assembly manifest located close to Test_debug.dll should make this directory an assembly and make my Test_debug.dll findable, but I'm not sure and seems like I'm missing something

  • Docs say "type" value must be all lower case. – Dúthomhas May 26 '22 at 00:43
  • eh according to docs I think I should have installed my `assembly` with my DLL resource under the `%WINDIR%\WinSxS\manifest\` via merge modules like `.msi` to make sure this assembly is `shared assembly` therefore visible when querying my assembly in my application, but for my purposes it's bad idea because I have more than 60 applications that need this one DLL, I don't want to have copies of DLL, BUT I don't want to install any assembly in system paths either so I rather stay with `LoadLibrary` probably – AnastaZIuk May 26 '22 at 09:21
  • Oh! I resolved my issues with this helpful comment https://stackoverflow.com/a/1973332/13906958 following those instructions will let you avoid PATH env variable and go with private assemblies – AnastaZIuk May 26 '22 at 10:56

0 Answers0