Click here to Skip to main content
13,357,610 members (64,885 online)
Click here to Skip to main content
Add your own
alternative version


23 bookmarked
Posted 18 Jun 2005

Editing an assembly's manifest and more...

, 18 Jun 2005
Rate this:
Please Sign up or sign in to vote.
An article on editing an assembly's manifest and some other IL attributes.


This article will provide a step-by-step guide to editing an assembly's manifest and a brief example of how easy it is to modify an assembly.

The Problem

Working in a larger development team means that you may not always have access to source code for a particular assembly, or if you do, you may not be able to compile it for whatever reason (e.g. you are out at a client site).

I recently had two problems that I solved by disassembling an assembly, modifying the manifest and IL and then reassembling it.

The attached code (above) has two projects. The first project is a WinForms project that uses a class library. The class library has the following lines of code:

using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: AssemblyVersion("")]

public class TestClass
    public static decimal SquareNumber(decimal baseNumber)
        return CalculatePower(baseNumber, 2);

    private static decimal CalculatePower(decimal baseNumber, int exponent)
        decimal returnValue = 1;

        for (int i = 0; i < exponent; i++)
            returnValue *= baseNumber;

        return returnValue;

Let's suppose for an instant that our class library is used in a number of places and we are recompiling it to fix a problem in a previous version. We need to distribute this to our client but we have compiled it for the wrong version and cannot use the new assembly because of version dependency problems.

Some new functionality in our WinForms application needs access to the CalculatePower method, which unfortunately has a private accessor. This means we will need to change its accessor to public instead of private (see below).

MessageBox.Show (TestClass.CalculatePower(decimal.Parse(txtBase.Text), 

The Solution

Thankfully, Microsoft has included all the tools you need to do this with Visual Studio .NET.

  1. Start the Visual Studio .NET 2003 Command Prompt.

    Visual Studio .NET Command Prompt

  2. At the command prompt, type ildasm <enter>.
  3. Open the assembly that you need to work on. In our case, this will be SatelliteAssembly.dll.
  4. After opening the file, select File->Dump. Ensure all checkboxes are selected and then click OK.
  5. You will be prompted to save it as an IL file. I recommend creating a new directory to save in. Save as SatelliteAssembly.IL (then close ILDASM).
  6. Open SatelliteAssembly.IL inside your favourite editing tool (I use Visual Studio .NET 2003).
  7. Find the IL code that looks like this:
    .assembly /*20000001*/ SatelliteAssembly
      // --- The following custom attribute is added
      //                   automatically, do not uncomment -------
      //  .custom /*0C000001:0A000002*/ instance void [mscorlib/* 23000001 */]
      //         System.Diagnostics.DebuggableAttribute/* 01000004 */::.ctor(bool,
      //         bool) /* 0A000002 */ = ( 01 00 01 01 00 00 ) 
      .hash algorithm 0x00008004 
      .ver 1:0:1:0
  8. Change the version 1:0:1:0 ( to 2:0:1:0 (
  9. Find the IL code that looks like this:
    .method /*06000002*/ private hidebysig static
            valuetype [mscorlib/* 23000001 */]System.Decimal/* 01000002 */
            CalculatePower(valuetype [mscorlib/* 23000001 */]
              System.Decimal/* 01000002 */ baseNumber,
              int32 exponent)}
  10. Change the private accessor to public.
  11. Ensure that the command prompt working directory is the temporary directory that you used to save the IL file.
  12. At the command prompt, type ilasm /DLL SatelliteAssembly.IL <enter>.

You will now be left with an assembly that has the new version number and the public method accessor. This can come in handy when you don't have explicit access to the source code or the source code is unavailable.

Points of Interest

Obviously, the power that is provided by the disassembly / assembly is quite phenomenal and there are many other tweaks and changes that can be provided by this facility.

I have not tried this method on obfuscated code (for development, our code is not obfuscated). If you have tried this on obfuscated code, let me know how it worked out.

ILASM has a number of switches that you may like to investigate (e.g. /DEBUG provides the .PDB file for debug information).


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Simon McEnlly
Web Developer
Australia Australia
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionSigned Assemblies Pin
AmirAlilou16-Jan-14 4:01
memberAmirAlilou16-Jan-14 4:01 
Questionupdating manifest of an assembly Pin
shilpapc23-Nov-11 2:23
membershilpapc23-Nov-11 2:23 
GeneralNice!!! Pin
Palanisamy Veerasingam19-Jul-07 5:17
memberPalanisamy Veerasingam19-Jul-07 5:17 
GeneralToo cool Pin
DhananjayShenolikar12-Jul-07 3:18
memberDhananjayShenolikar12-Jul-07 3:18 
GeneralToo good Pin
jigjosh5-Sep-06 3:30
memberjigjosh5-Sep-06 3:30 
GeneralThanks Pin
oykica19-Jun-05 16:34
memberoykica19-Jun-05 16:34 
Generalit's a good tutorial Pin
silas_yao18-Jun-05 19:09
membersilas_yao18-Jun-05 19:09 
simple! Perfect!

MCSE 1999

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180111.1 | Last Updated 18 Jun 2005
Article Copyright 2005 by Simon McEnlly
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid