Friday, August 27, 2021

Rename AppDomain.CurrentDomain.GetAssemblies() in runtime with Reflection.

If you need to rename the  'AppDomain.CurrentDomain.GetAssemblies()' for testing, here is something you can try:

 

 public static void RenameCurrentDomainAssemblies()

{

foreach (var a in AppDomain.CurrentDomain.GetAssemblies().Where(a => a.FullName.StartsWith("System")))

{

FieldInfo fullName = a.GetType().GetField("m_fullname", BindingFlags.Instance | BindingFlags.NonPublic);

fullName.SetValue(a, "Gotcha");

}


AppDomain.CurrentDomain.GetAssemblies().Where(a => a.FullName.StartsWith("SyS")).Dump();

}

No comments:

Post a Comment

Stats


View My Stats

Contributors