/// <summary> /// This is an oddity under TVPack, sometimes the MediaCenterEnvironemt and MediaExperience objects go bad and become /// disconnected from their host in the main application. Typically this is after 5 minutes of leaving the application idle (but noot always). /// What is odd is that using reflection under these circumstances seems to work - even though it is only doing the same as Reflector shoulds the real /// methods do. As I said it's odd but this at least lets us get a warning on the screen before the application crashes out! /// </summary> /// <param name="message"></param> public static void DialogBoxViaReflection(string message) { MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment; FieldInfo fi = ev.GetType().GetField("_legacyAddInHost", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance); if (fi != null) { AddInHost2 ah2 = (AddInHost2)fi.GetValue(ev); if (ah2 != null) { Type t = ah2.GetType(); PropertyInfo pi = t.GetProperty("HostControl", BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Public); if (pi != null) { HostControl hc = (HostControl)pi.GetValue(ah2, null); hc.Dialog(message, "Media Browser", 1, 120, true); } } } }