How to patch/fix/hack someone else’s assembly
Here is my recipe when I can see no workaround to a defect or other problem and want to get around it. This is not for the faint hearted and I do not recommend it for production!
1. Extract source code and patch code
You need to use Roaders’ Reflector to export the assembly. Right-click on top node and select Export…
Then comment out offending lines, add your logging, or patch defects.
2. Recompile strong-named assembly with only the public-key
Extract the public key from the existing assembly with the Strong Name Tool:
sn -e C:xxxbinStarCommunity.Core.dll C:tempNetstar.snk
Since we do not have the private key we must compile with delayed signing. Change the exported AssemblyInfo.cs:
[assembly: System.Reflection.AssemblyDelaySign(true)] [assembly: System.Reflection.AssemblyKeyFile(@"Netstar.snk")]
Build project and replace the assembly in the web applications bin-folder.
3. Get the assembly to load without signing
Disable Strong Name verification so the dot net framework accepts the patched assembly without signing. Use the Strong Name tool and tell it to skip verification on all assemblies with the public key you exported above.
sn -Vr *,0bd7a6276e8c109e
NOTE: The hex code above is from the public-key used by NetStar but you must change it to match the public key in your assembly. The change is global on the machine.
4. Restart and test
Policy changes requires a restarts so do a IISReset to get the patched assembly to load.
Happy coding!