changing Remoting's customError attribute using code

I bloged about this HERE. I got this code from saar from my team - A real wiz kid. use on your own risk

In theory this code should change the "custom errors" remoting property under .Net framework 1.1 The code changes some internal values, so it might not work on another 1.1. You should think twice(!) before you paste it into your application(!).

public void Foo()

{

    const string Value = "Off";

    Type configType = Type.GetType ("System.Runtime.Remoting.RemotingConfigHandler");

    System.Diagnostics.Debug.Assert (configType != null);

    Type modesType = Type.GetType ("System.Runtime.Remoting.CustomErrorsModes");

    object o = System.Enum.Parse (modesType, Value, true);

    PropertyInfo pi = configType.GetProperty ("CustomErrorsMode", BindingFlags.NonPublic | BindingFlags.Static);

    pi.SetValue (null, o, new object[0]);

}