Skip to content

Instantly share code, notes, and snippets.

@jbevain
Created July 30, 2009 10:22
Show Gist options
  • Save jbevain/158643 to your computer and use it in GitHub Desktop.
Save jbevain/158643 to your computer and use it in GitHub Desktop.
Tool to rebase System.Reactive to the .net framework
using System;
using System.Globalization;
using System.Linq;
using Mono.Cecil;
class Rebase {
static void Main ()
{
const string file = "System.Reactive.dll";
var assembly = AssemblyFactory.GetAssembly (file);
assembly.Name.PublicKey = null;
assembly.Name.HasPublicKey = false;
foreach (AssemblyNameReference reference in assembly.MainModule.AssemblyReferences) {
switch (reference.Name) {
case "mscorlib":
case "System":
reference.Version = new Version (2, 0, 0, 0);
break;
case "System.Core":
reference.Version = new Version (3, 5, 0, 0);
break;
}
reference.PublicKeyToken = GetPublicKeyToken ("b77a5c561934e089");
}
AssemblyFactory.SaveAssembly (assembly, file);
}
static byte [] GetPublicKeyToken (string str)
{
var pktoken = new byte [str.Length / 2];
for (int i = 0; i < pktoken.Length; i++)
pktoken [i] = Byte.Parse (str.Substring (i * 2, 2), NumberStyles.HexNumber);
return pktoken;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment