VisualStudio:Manifest
lastmod 2019-09-09created 2019-09-094 edits
About
Honestly, the part I never paid attention to while using Visual Studio 2005 (VS2005) is the existence of this manifest file. I suspect many of the people reading this will also think, "What's that?" The importance of this manifest shows up when you try to run a program you made on another computer.
First, you need to know about the .NET Framework. You don't need to know everything; simply put, think of it as the thing that makes programs written with VS2005 run well regardless of the computer's spec. That is, it makes the program I wrote run well regardless of whether the computer has a 4-byte int or an 8-byte int (whether it's a 32-bit or 64-bit computer). Common sense says that if the .NET Framework makes my program run well regardless of the computer, then the .NET Framework either has something in common or generates Binary code (executable code) suited to that computer according to unified rules.
Let's look at the .NET Framework Assemblies. These are partially compiled dll files. They are called and used at the time the program runs (when the CLR generates machine code using the Just-in-time complier). In a word, they are a library storing the necessary information. The important part starts here: when you write a program with VS2005, VS2005 by default generates something called a manifest file. This manifest file describes which .NET Framework Assemblies the built program uses, what their versions are, what the dependencies are, and so on. Anyone who has built a program with VS2005 even once will have seen a file containing the word manifest generated in the Debug or Release folder. If you open that file, its contents include a part like this,
<assemblyIdentity type="win32" name="Microsoft.VC80.DebugCRT" version="8.0.50727.762"
processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
This shows in detail which version of the .NET Assemblies is being used, whether it is Debug or Release, whether it is x86 or not, and even the publickey. What to note here is name and version. Open the folder called WinSxS under the Windows folder. Inside, you will see folders similar to that name, with the version number after the folder name. The WinSxS folder shows all Shared Side-by-Side Assemblies installed on the current computer. In short, it is the folder containing all .NET Framework Assemblies provided on this computer. If you run a program and it absurdly throws the error This system cannot execute from this program., first open the manifest file that sits with the executable. Then open that computer's WinSxS folder and check whether the assembly exists.
If there is no folder matching the Version listed in the manifest file, the computer emits the "ridiculous" error message that it cannot run the program because it lacks the data needed to run it. The ways to solve this are as follows.
- If VS 2005 or VS 2008 is installed on the computer, update it. (Updating automatically installs newer versions of the assemblies.)
- Open the Manifest, find the DLL files of the corresponding version, and copy them into the folder with the executable. This is not guaranteed to work 100%. If the .NET Framework isn't even installed, it probably won't work.
- Download and install the Microsoft Visual C++ Redistribution Package.
Installing the Redistribution Package is the most sensible method. If you search Google for Visual C++ Redistribution package, separate downloads for Visual Studio 2005 and 2008 come up. Downloading and installing this file automatically installs the assemblies of that version into the WinSxS folder, and people without Visual Studio can run the program too.
WinSxS(Windows Side By Side) Assembly (Manifest)
- Manifest (WinSxS)
- Overview of WinSxS and manifests
- MSDN /MANIFEST (Create side-by-side assembly manifest)
Manifest-related problems can occur when compiling with MD or MDD rather than MT or MTD in the MSVC compile options. Strictly speaking, from VS2005 onward you can't easily use the CRT, MFC, or ATL DLLs.
Manifest (.NET Framework)
An assembly manifest is a text file containing metadata about .NET assemblies. It describes the relationship and dependencies of the components in the assembly, versioning information, scope information and the security permissions required by the assembly. The manifest information embedded within an assembly can be viewed using IL Disassembler (ILDASM.exe) which is available as part of Microsoft Windows SDK.
Solution when using MD or MDD
Open the .manifest file of the exe you want to distribute (it's XML). If standard DLLs are used, check their versions. Check whether the dlls of that version are in the folder with the exe file. If not, check whether they are in the Windows\WinSxS folder. (From VS2005 on, you don't need to care about Windows\System32.) If the program won't run because the DLLs are missing, get the latest MFC, CRT, and ATL DLL redistributables using the following search keywords.
Keyword
- Microsoft Visual C++ 2005 Redistributable
- Microsoft Visual C++ 2008 Redistributable
- Microsoft Visual C++ 2010 Redistributable