VSoft/Source/VSoftBox/Program.cs

60 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
#if DY
using System.Reflection;
#endif
using System.Windows.Forms;
using VSoft.Config;
namespace VSoftBox
{
static class Program
{
#if DY
/// <summary>
/// 流程软件路径
/// </summary>
static string ProcessPath;
#endif
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
#if DY
var sub_dir = @"\SysDb\Tools\VSoft";
if (Application.StartupPath.EndsWith(sub_dir, StringComparison.OrdinalIgnoreCase))
{
ProcessPath = Application.StartupPath.Substring(0, Application.StartupPath.Length - sub_dir.Length);
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
Soft_Info.UserDataFolder = ProcessPath+"\\UserDb\\Tools\\VSoft";
}
#endif
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Init.Show(args);
}
#if DY
static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
AssemblyName assemblyName = new AssemblyName(args.Name);
if (System.IO.File.Exists(ProcessPath + @"\" + assemblyName.Name + ".dll"))
{
return Assembly.LoadFrom(ProcessPath + @"\" + assemblyName.Name + ".dll");
}
else if (System.IO.File.Exists(ProcessPath + @"\Bin\dlls\" + assemblyName.Name + ".dll"))
{
return Assembly.LoadFrom(ProcessPath + @"\Bin\dlls\" + assemblyName.Name + ".dll");
}
else
{
return args.RequestingAssembly;
}
}
#endif
}
}