private void OnLoadLibrarySucc2(WWW www) { LogSystem.LogWarning(new object[] { "OnLoadLibrarySucc:" }); if (www == null || www.assetBundle == null) { this.OnLoadLibraryError2(www); return; } LogSystem.LogWarning(new object[] { "OnLoadLibrarySucc:1" }); TextAsset textAsset = www.assetBundle.Load("GameLib") as TextAsset; if (textAsset == null) { this.muiGuide.ShowMBox(3, Config.GetUdpateLangage("LoadLibraryError"), new EventDelegate.Callback(this.LoadScriptLib), new EventDelegate.Callback(LaunchUtils.OnErrorQuit), string.Empty); return; } this.mRemoteAssembly = CoreLoader.LoadDllFile(textAsset.bytes); www.assetBundle.Unload(true); if (this.mRemoteAssembly == null) { this.muiGuide.ShowMBox(3, Config.GetUdpateLangage("LoadLibraryError"), new EventDelegate.Callback(this.LoadScriptLib), new EventDelegate.Callback(LaunchUtils.OnErrorQuit), string.Empty); return; } this.StartUpdater(); }
/// <summary> /// Main method that is invoked by SubmitJob Program /// </summary> /// <param name="args"></param> public static void Main(string[] args) { var getIp = GetLocalIpAddress(); getIp.Wait(); // try to connect to the NodeManager var jobRef = new JobRef(); var loader = new CoreLoader <Job>(args[0]); var userArgs = new string[args.Length - 1]; for (var i = 1; i < args.Length; i++) { userArgs[i - 1] = args[i]; } // setup the job reference jobRef.RequestedNodes = (int)loader.CallMethod("RequestedNodes", new object[] {}); jobRef.Username = GetUserName(); jobRef.PathToDll = args[0]; jobRef.FileName = Path.GetFileName(args[0]); Console.WriteLine(jobRef.FileName); jobRef.UserArgs = userArgs; // call the initial method loader.CallMethod("RunInitialTask", new object[] {}); var sj = new SubmitJob(_ipAddr, NetworkSendReceive.ServerPort, jobRef); Console.CancelKeyPress += sj.OnUserExit; }
public static void Main2(string[] args) { CoreLoader <Foo> foo = new CoreLoader <Foo>("PathToDllContainingFoo"); int x = (int)foo.GetProperty("MyIntegerProperty"); foo.CallMethod("MySimpleMethod", new object[] {}); var result = (string)foo.CallMethod( "MyLessSimpleMethod", new object[] { 1, "hello", 3.4 }); }
static void Main() { var args = Environment.GetCommandLineArgs(); if (GetCommandLineSwitch("/?", args) || GetCommandLineSwitch("/h", args) || GetCommandLineSwitch("/help", args)) { PrintCommandLineParameters(); Environment.Exit(0); return; } var logFile = GetCommandLineParameter("/log", args); if (logFile != null) { try { Logger.Out = File.CreateText(logFile); } catch (Exception e) { Logger.LogWarn(e, "Unable to open log file at '{0}'", logFile); } } #if DEBUG Logger.LogLevel = 5; #endif if (int.TryParse(GetCommandLineParameter("/loglevel", args), NumberStyles.Any, null, out var logLevel)) { Logger.LogLevel = logLevel; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.VisualStyleState = VisualStyleState.ClientAndNonClientAreasEnabled; Application.ThreadException += ApplicationThreadException; Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException; AppDomain.CurrentDomain.FirstChanceException += CurrentDomainFirstChanceException; ThreadPool.SetMaxThreads(50, 200); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; // Permit unmanaged code permissions new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert(); DisableExceptionReporter = GetCommandLineSwitch("/DisableExceptionReporter", args); #if DEBUG System.Windows.Forms.Timer watchdogTimer; #endif bool mutexAquired = false; using (var mutex = new Mutex(false, GlobalMutexId)) { Logger.LogNotice($"ContactPoint IP Phone version: {typeof(Program).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion}"); Logger.LogNotice($"Main Thread Culture is '{Thread.CurrentThread.CurrentCulture}'"); Logger.LogNotice($"UI Thread Culture is '{Thread.CurrentThread.CurrentUICulture}'"); #if DEBUG if (args.Contains("/debugger", StringComparer.InvariantCultureIgnoreCase)) { if (Debugger.IsAttached) { Debugger.Break(); } else { Debugger.Launch(); } } #endif #if DEBUG watchdogTimer = new System.Windows.Forms.Timer { Interval = 3000 }; watchdogTimer.Tick += (s, e) => { _watcherLastActivity = DateTime.Now; }; watchdogTimer.Start(); _watcherTargetThread = Thread.CurrentThread; _watcherLastActivity = DateTime.Now; ThreadPool.QueueUserWorkItem(WatcherThreadFunc); #endif var makeCallMessage = StartPhoneCallCommand.CreateFromCommandLine(GetCommandLineParameter("/call", args)); try { try { if (!WaitForMutex(mutex)) { SharedFileMessageTransportHost.SendMessage(makeCallMessage); Environment.Exit(0); return; } else { mutexAquired = true; } } catch (Exception e) { Logger.LogError(e); Environment.Exit(-1); } using (AppContext = new MainFormApplicationContext()) { if (!GetCommandLineSwitch("/DisableSplashScreen", args)) { LoaderForm = new LoaderForm(); ThreadPool.QueueUserWorkItem(ShowSplashScreen); } CoreLoader.LoadingFailed += LoadingFailed; CoreLoader.PartLoading += PartLoading; foreach (var assembly in typeof(Program).Assembly.GetReferencedAssemblies()) { PartLoading($"Load dependency: {assembly.Name} v{assembly.Version}"); AppDomain.CurrentDomain.Load(assembly); } PartLoading("Initialize Exception Reporter"); ExceptionReporter = new ExceptionReporter.ExceptionReporter(); ExceptionReporter.Config.ShowFlatButtons = false; ExceptionReporter.Config.ShowLessMoreDetailButton = true; ExceptionReporter.Config.CompanyName = "ContactPoint"; ExceptionReporter.Config.ContactEmail = "*****@*****.**"; ExceptionReporter.Config.WebUrl = "http://www.contactpoint.com.ua/"; #if DEBUG ExceptionReporter.Config.ShowFullDetail = true; #else ExceptionReporter.Config.ShowFullDetail = false; #endif // Create WPF application in order to let WPF controls work correctly PartLoading("Initialize WPF Infrastructure"); System.Windows.Application wpfApp = null; Window wpfWnd = null; try { PartLoading("Create WPF Application"); wpfApp = new System.Windows.Application(); PartLoading("Create WPF Window"); wpfWnd = new Window { Visibility = Visibility.Hidden, ShowInTaskbar = false, Width = 1, Height = 1 }; PartLoading("Core infrastructure"); using (var core = CoreLoader.CreateCore(AppContext.MainForm)) { PartLoading("Audio services"); using (new AudioDeviceService(core)) { #if DEBUG if (args.Contains("/newui")) { new PhoneWindow().Show(); } #endif PartLoading("Configuring WinForms Infrastructure"); AppContext.ContactPointForm.Core = core; AppContext.ContactPointForm.CallOnStartup = makeCallMessage; AppContext.ContactPointForm.DisableSettingsFormAutoStartup = GetCommandLineSwitch("/DisableSettingsFormAutoStartup", args); AppContext.ContactPointForm.Shown += MainFormShown; PartLoading("Starting WinForms UI"); Application.Run(AppContext); } } } finally { wpfWnd?.Close(); wpfApp?.Shutdown(0); } } } finally { if (mutexAquired) { mutex.ReleaseMutex(); } #if DEBUG _watcherThreadShutdown = true; watchdogTimer.Stop(); #endif } } }
public JobSender(JobRef job, SubmitJob parent) { _parent = parent; _job = job; _loader = new CoreLoader <Job>(_job.PathToDll); }