18

In the following manifest, is it necessary to change the version attribute of the assemblyIdentity element if the assembly version is specified in the project (or, in my case, set as part of a MSBuild task)?

According to this Microsoft Connect page, it looks like the project's version number overrides the manifest's version number. Please correct me if I'm wrong...

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" 
                xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" 
                xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="MyApp.exe" type="win32"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</asmv1:assembly>
StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Mark Carpenter
  • 17,445
  • 22
  • 96
  • 149

2 Answers2

7

The point of the assembly information is to uniquely identify your application to Windows and it's components. This is similar to how .NET uses filename + version + ID generated + target processor arch to identify assemblies uniquely.

If you choose not to change it then Windows components may not see new versions of your application as uniquely different from old versions.

More information on the Application Manifests MSDN page.

Robert MacLean
  • 38,975
  • 25
  • 98
  • 152
0

Based on Microsoft's documentation, it appears that YES, the exact version number must be specified:

Assembly Versions

01/07/2021

The version must be specified in assemblyIdentity elements of manifests. Use the four-part version format: mmmmm.nnnnn.ooooo.ppppp.

This reference makes no exceptions; e.g., you can't use mmmmm.nnnnn.*.* or something like that, it has to be exact.


I have attempted to load a NEWER DLL which had an OLDER version specified in the manifest. This fails with the error:

"The application has failed to start because its side-by-side configuration is incorrect"

Using sxstrace I could see the detailed error was ERROR: Component identity found in manifest does not match.

Here's the full trace (the final 4 lines are the key part):

    INFO: Resolving reference SomeAssemblyName,processorArchitecture="msil",version="1.0.8047.21177".
        INFO: Resolving reference for ProcessorArchitecture msil.
            INFO: Resolving reference for culture Neutral.
                INFO: Applying Binding Policy.
                    INFO: No binding policy redirect found.
                INFO: Begin assembly probing.
                    INFO: Did not find the assembly in WinSxS.
                    INFO: Attempt to probe manifest at C:\Program Files (x86)\folder\SomeAssemblyName.DLL.
                    INFO: Manifest found at C:\Program Files (x86)\folder\SomeAssemblyName.DLL.
                INFO: End assembly probing.

    INFO: Parsing Manifest File C:\Program Files (x86)\folder\SomeAssemblyName.DLL.
        INFO: Manifest Definition Identity is SomeAssemblyName,processorArchitecture="msil",version="1.0.8047.30356".
        ERROR: Component identity found in manifest does not match the identity of the component requested. 
           Reference is SomeAssemblyName,processorArchitecture="msil",version="1.0.8047.21177". 
           Definition   SomeAssemblyName,processorArchitecture="msil",version="1.0.8047.30356".
    ERROR: Activation Context generation failed.

So it finds the assembly and compares the version, and when they don't match it rejects it.

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81