No matter what I do, I can't seem to figure out how to
programmatically remove the strong name from one of my signed
assemblies. Here's the test code:
var nameDef = sourceAssembly.Name;
// Remove the strong name
nameDef.PublicKey = new byte[0];
nameDef.PublicKeyToken = new byte[0];
nameDef.Flags = AssemblyFlags.SideBySideCompatible;
nameDef.HasPublicKey = false;
// Remove any strong name references
var module = sourceAssembly.MainModule;
foreach(AssemblyNameReference reference in
module.AssemblyReferences)
{
reference.PublicKeyToken = new byte[0];
}
When I try to load the modified assembly into memory, it gives me this
error:
System.BadImageFormatException: Could not load file or assembly '4880
bytes loaded from [Your Assembly Here], Version=2.0.3.38038,
Culture=neutral, PublicKeyToken=null' or one of its dependencies. An
attempt was made to load a program with an incorrect format.
Am I missing something here? Is there some other thing that I have to
do to the newly-unsigned assembly itself before I can load it into
memory?
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---