Beispiel #1
0
 private void RunXRef(XRefArguments options)
 {
     try
     {
         AppendTextToLogTextBoxAsync("Running MixinXRef...");
         CrossAppDomainCommunicator.MessageReceivedDelegate onMessageReceived = (severity, message) => AppendTextToLogTextBoxAsync(message);
         new XRefInAppDomainRunner().Run(null, options, onMessageReceived);
     }
     catch (ArgumentException ex)
     {
         Action messageBoxDisplayer = () => MessageBox.Show(this, ex.Message, "Configuration error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         BeginInvoke(messageBoxDisplayer);
     }
 }
Beispiel #2
0
        public int Run(string[] talkBackArgs, XRefArguments xRefArgs, CrossAppDomainCommunicator.MessageReceivedDelegate onMessageReceived = null)
        {
            // Create new application domain and run cross referencer
            var appDomain = AppDomain.CurrentDomain;

            var setupInformation = appDomain.SetupInformation;

            setupInformation.ApplicationBase = xRefArgs.AssemblyDirectory;

            if (!string.IsNullOrEmpty(xRefArgs.AppBaseDirectory))
            {
                setupInformation.ApplicationBase = xRefArgs.AppBaseDirectory;

                var appBaseDirectory = xRefArgs.AppBaseDirectory;
                if (!appBaseDirectory.EndsWith("\\"))
                {
                    appBaseDirectory += "\\";
                }

                if (xRefArgs.AssemblyDirectory.StartsWith(appBaseDirectory))
                {
                    var relativeSearchPath = xRefArgs.AssemblyDirectory.Remove(0, appBaseDirectory.Length);
                    if (!string.IsNullOrEmpty(relativeSearchPath))
                    {
                        setupInformation.PrivateBinPath = relativeSearchPath;
                    }
                }
                else
                {
                    throw new ArgumentException("Input directory is not a sub directory of application base directory!");
                }
            }
            if (!string.IsNullOrEmpty(xRefArgs.AppConfigFile))
            {
                if (!File.Exists(xRefArgs.AppConfigFile))
                {
                    throw new ArgumentException(string.Format("Supplied app-config file '{0}' does not exist.", xRefArgs.AppConfigFile));
                }

                setupInformation.ConfigurationFile = xRefArgs.AppConfigFile;

                // The PrivateBinPath needs to be read manually from the config because for some reason it does not via automatic setup.
                var privateBinPath = GetPrivateBinPathFromConfig(xRefArgs.AppConfigFile);
                if (!string.IsNullOrEmpty(privateBinPath))
                {
                    if (string.IsNullOrEmpty(setupInformation.PrivateBinPath))
                    {
                        setupInformation.PrivateBinPath = privateBinPath;
                    }
                    else
                    {
                        setupInformation.PrivateBinPath = setupInformation.PrivateBinPath + ";" + privateBinPath;
                    }
                }
            }

            var newAppDomain = AppDomain.CreateDomain("XRefAppDomain", appDomain.Evidence, setupInformation, new PermissionSet(PermissionState.Unrestricted));
            var crossAppDomainCommunicatorType = typeof(CrossAppDomainCommunicator);
            var proxy = (CrossAppDomainCommunicator)newAppDomain.CreateInstanceFromAndUnwrap(crossAppDomainCommunicatorType.Assembly.Location, crossAppDomainCommunicatorType.FullName);

            if (onMessageReceived != null)
            {
                proxy.SetMessageReceivedDelegate(new MessageReceivedDelegateWrapper(onMessageReceived).OnMessageReceived);
            }
            return(proxy.Run(talkBackArgs, xRefArgs));
        }
Beispiel #3
0
 public MessageReceivedDelegateWrapper(CrossAppDomainCommunicator.MessageReceivedDelegate onMessageReceived)
 {
     _onMessageReceived = onMessageReceived;
 }
 public MessageReceivedDelegateWrapper(CrossAppDomainCommunicator.MessageReceivedDelegate onMessageReceived)
 {
     _onMessageReceived = onMessageReceived;
 }