Program.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.IO;
  3. using System.Reflection;
  4. using Avalonia.DesignerSupport;
  5. using Avalonia.Markup.Xaml;
  6. namespace Avalonia.Designer.HostApp
  7. {
  8. class Program
  9. {
  10. #if NET461
  11. private static string s_appDir;
  12. private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
  13. {
  14. string assemblyPath = Path.Combine(s_appDir, new AssemblyName(args.Name).Name + ".dll");
  15. if (File.Exists(assemblyPath) == false) return null;
  16. return Assembly.LoadFile(assemblyPath);
  17. }
  18. public static void Main(string[] args)
  19. {
  20. s_appDir = Directory.GetCurrentDirectory();
  21. AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
  22. foreach (var dll in Directory.GetFiles(s_appDir, "*.dll"))
  23. {
  24. try
  25. {
  26. Console.WriteLine("Loading " + dll);
  27. Assembly.LoadFile(dll);
  28. }
  29. catch
  30. {
  31. }
  32. }
  33. Exec(args);
  34. }
  35. static void Exec(string[] args)
  36. #else
  37. public static void Main(string[] args)
  38. #endif
  39. {
  40. AvaloniaLocator.CurrentMutable.Bind<AvaloniaXamlLoader.IRuntimeXamlLoader>()
  41. .ToConstant(new DesignXamlLoader());
  42. Avalonia.DesignerSupport.Remote.RemoteDesignerEntryPoint.Main(args);
  43. }
  44. }
  45. }