Program.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using DevExpress.LookAndFeel;
  2. using DevExpress.Skins;
  3. using DevExpress.UserSkins;
  4. using DevExpress.XtraEditors;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Diagnostics;
  8. using System.Linq;
  9. using System.Reflection;
  10. using System.Windows.Forms;
  11. namespace XdCxRhDW.DataEmulation
  12. {
  13. public class Father
  14. {
  15. public int A { get; set; }
  16. }
  17. public class Son : Father
  18. {
  19. public int B { get; set; }
  20. }
  21. internal static class Program
  22. {
  23. static Program()
  24. {
  25. AppDomain.CurrentDomain.SetData("PRIVATE_BINPATH", "AddIns;");
  26. var m = typeof(AppDomainSetup).GetMethod("UpdateContextProperty", BindingFlags.NonPublic | BindingFlags.Static);
  27. var funsion = typeof(AppDomain).GetMethod("GetFusionContext", BindingFlags.NonPublic | BindingFlags.Instance);
  28. m.Invoke(null, new object[] { funsion.Invoke(AppDomain.CurrentDomain, null), "PRIVATE_BINPATH", "AddIns;" });
  29. AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
  30. {
  31. var args = e.ExceptionObject as Exception;
  32. DxHelper.MsgBoxHelper.ShowError("出现未处理的异常,程序即将退出!");
  33. };
  34. Application.ThreadException += (sender, e) =>
  35. {
  36. DxHelper.MsgBoxHelper.ShowError(e.Exception.Message);
  37. };
  38. }
  39. /// <summary>
  40. /// The main entry point for the application.
  41. /// </summary>
  42. [STAThread]
  43. static void Main()
  44. {
  45. Father f = new Father() { A = 1 };
  46. Son s = (Son)f;
  47. WindowsFormsSettings.AllowDpiScale = true;
  48. WindowsFormsSettings.AllowHoverAnimation = DevExpress.Utils.DefaultBoolean.True;
  49. WindowsFormsSettings.AllowDefaultSvgImages = DevExpress.Utils.DefaultBoolean.True;
  50. WindowsFormsSettings.AllowRoundedWindowCorners = DevExpress.Utils.DefaultBoolean.True;
  51. WindowsFormsSettings.AnimationMode = AnimationMode.EnableAll;
  52. WindowsFormsSettings.BackgroundSkinningMode = BackgroundSkinningMode.AllColors;
  53. WindowsFormsSettings.DefaultAllowHtmlDraw = true;
  54. WindowsFormsSettings.DefaultLookAndFeel.SetSkinStyle(SkinStyle.WXICompact);
  55. WindowsFormsSettings.DefaultFont = new System.Drawing.Font("微软雅黑", 10f);
  56. WindowsFormsSettings.SetPerMonitorDpiAware();
  57. if (Debugger.IsAttached)
  58. {
  59. //DevExpress23.2以上版本查看未本地化的资源
  60. //DevExpress.Utils.Localization.XtraLocalizer.EnableTraceSource();
  61. }
  62. Application.EnableVisualStyles();
  63. Application.SetCompatibleTextRenderingDefault(false);
  64. Application.Run(new Form1());
  65. }
  66. }
  67. }