-
-
Save chamons/f5de79eccc1aa775daa528da6aa17af3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void UseReflectionToHackAround_44707 () | |
{ | |
// As it says on the tin, this uses reflection to hack around bug 44707 | |
// If mono changes their implementaiton at all, it will stop working, and throw InvalidOperationException | |
// First figure out where the config we ship inside the bundle is | |
string path = NSBundle.MainBundle.ResourceUrl.Append ("../MonoBundle/config", false).ToString ().Replace ("file://", ""); | |
// Then force mono to load that instead | |
MethodInfo readConfigMethod = typeof (RemotingConfiguration).GetMethod ("ReadConfigFile", BindingFlags.NonPublic | BindingFlags.Static); | |
if (readConfigMethod == null) | |
throw new System.InvalidOperationException ("UseReflectionToHackAround_44707 failed due to mono changing implementation"); | |
readConfigMethod.Invoke (this, new object[] { path }); | |
// And then set the property that we already read it | |
FieldInfo defaultReadProp = typeof (RemotingConfiguration).GetField ("defaultConfigRead", BindingFlags.NonPublic | BindingFlags.Static); | |
if (defaultReadProp == null) | |
throw new System.InvalidOperationException ("UseReflectionToHackAround_44707 failed due to mono changing implementation"); | |
defaultReadProp.SetValue (null, true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment