public static void UpdateAdditionalRefs(QueryCore q)
 {
     try
     {
         _query          = q;
         _additionalRefs = q.AllFileReferences.Union <string>((from r in q.AdditionalGACReferences
                                                               select GacResolver.FindPath(r) into r
                                                               where r != null
                                                               select r)).ToArray <string>();
     }
     catch
     {
         _additionalRefs = "".Split(new char[0]);
     }
 }
Exemple #2
0
        private static string GetEfPath(IConnectionInfo cxInfo, bool convertFullNameToGacPath)
        {
            string efVersion;
            string customAssemblyPath = cxInfo.CustomTypeInfo.CustomAssemblyPath;

            if (string.IsNullOrEmpty(customAssemblyPath))
            {
                return(null);
            }
            try
            {
                string path = Path.Combine(Path.GetDirectoryName(customAssemblyPath), "EntityFramework.dll");
                if (File.Exists(path))
                {
                    return(path);
                }
            }
            catch (ArgumentException)
            {
            }
            if (customAssemblyPath == _lastEfPathInput)
            {
                return(convertFullNameToGacPath ? _lastEfPathGac : _lastEfPath);
            }
            _lastEfPath = null;
            string   shortName      = Path.GetFileNameWithoutExtension(customAssemblyPath);
            Assembly customAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault <Assembly>(a => a.GetName().Name.Equals(shortName, StringComparison.InvariantCultureIgnoreCase));

            if (customAssembly != null)
            {
                efVersion = new EFVersionProber().GetEfVersion(customAssembly);
            }
            else
            {
                using (DomainIsolator isolator = new DomainIsolator("Probe EF version"))
                {
                    efVersion = isolator.GetInstance <EFVersionProber>().GetEfVersion(customAssemblyPath);
                }
            }
            _lastEfPath = efVersion;
            string str5 = _lastEfPathGac = GacResolver.FindPath(efVersion);

            _lastEfPathInput = customAssemblyPath;
            return(convertFullNameToGacPath ? str5 : efVersion);
        }
Exemple #3
0
        public void RecreateDomain()
        {
            // don't recreate this domain unless it has actually loaded an assembly
            if (!_hasLoadedAssembly && _domain != null)
                return;

            if (_domain != null)
                AppDomain.Unload(_domain);

            _resolver = null;
            _domain = AppDomain.CreateDomain("GacCacheDomain",
                AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation);
            _hasLoadedAssembly = false;
        }
        public bool CanResolveSystem(string assemblyName)
        {
            string test;

            return(GacResolver.AssemblyExist(assemblyName, out test));
        }
Exemple #5
0
        public void RecreateDomain()
        {
            // don't recreate this domain unless it has actually loaded an assembly
            if (!_hasLoadedAssembly && _domain != null)
                return;

            if (_domain != null)
                AppDomain.Unload(_domain);

            _resolver = null;
            #if NET_4_0
            PermissionSet domainPermSet = new PermissionSet(PermissionState.Unrestricted);
            _domain = AppDomain.CreateDomain("GacCacheDomain", AppDomain.CurrentDomain.Evidence,
                AppDomain.CurrentDomain.SetupInformation, domainPermSet);
            #else
            _domain = AppDomain.CreateDomain("GacCacheDomain",
                AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation);
            #endif
            _hasLoadedAssembly = false;
        }
Exemple #6
0
 private static void Run(string queryToLoad, bool runQuery, string activationCode, bool deactivate, bool noForward, bool noUpdate, string caller)
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     if (Environment.OSVersion.Version.Major >= 6)
     {
         try
         {
             SetProcessDPIAware();
         }
         catch
         {
         }
     }
     AutoSaver.Start();
     Wheeler.Register();
     if (Environment.OSVersion.Version.Major < 6)
     {
         ToolStripManager.RenderMode = ToolStripManagerRenderMode.System;
     }
     if (!((activationCode != null) || deactivate))
     {
         Splash = new LINQPad.UI.Splash();
         Splash.Show();
         Splash.Update();
     }
     Log.add_StringWriter(new Action <string>(Log.Write));
     Log.add_ExceptionWriter(new Action <Exception>(Log.Write));
     TypeResolver.ManyToOne  = Resources.ManyToOne;
     TypeResolver.OneToMany  = Resources.OneToMany;
     TypeResolver.OneToOne   = Resources.OneToOne;
     TypeResolver.ManyToMany = Resources.ManyToMany;
     TypeResolver.Results    = Resources.Results;
     TypeResolver.Column     = Resources.Column;
     TypeResolver.Key        = Resources.Key;
     TypeResolver.Database   = Resources.Database;
     TypeResolver.GetSameFolderReferences        = new Func <string, string[]>(AssemblyProber.GetSameFolderReferences);
     WSAgent.WebClientFactory                    = new Func <WebClient>(WebHelper.GetWebClient);
     WSAgent.FastWebClientFactory                = new Func <WebClient>(WebHelper.GetFastWebClient);
     WSAgent.BackupWebClientFactory              = new Func <WebClient>(WebHelper.GetBackupWebClient);
     WSAgent.CurrentVersionString                = VersionString;
     AutocompletionManager.PassiveAutocompletion = UserOptions.Instance.PassiveAutocompletion;
     AutocompletionManager.DisableLambdaSnippets = UserOptions.Instance.DisableLambdaSnippets;
     SnippetManager.set_LINQPadSnippetsFolder(UserOptions.Instance.GetCustomSnippetsFolder(false));
     WSAgent.DiagnosticMode = DiagnosticMode;
     AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Program.CurrentDomain_UnhandledException);
     if (deactivate)
     {
         WSAgent.Remove(true);
     }
     else
     {
         if (activationCode != null)
         {
             using (RegisterForm form = new RegisterForm(activationCode))
             {
                 form.ShowDialog();
                 return;
             }
         }
         if (!noUpdate)
         {
             Thread thread = new Thread(new ParameterizedThreadStart(UpdateAgent.RunServerComms))
             {
                 Name         = "Update Agent",
                 IsBackground = true
             };
             _updateThread = thread;
             _updateThread.Start(caller);
         }
         if (!string.IsNullOrEmpty(caller))
         {
             new Thread(delegate {
                 try
                 {
                     Thread.Sleep(0xbb8);
                     if (File.Exists(caller))
                     {
                         FileInfo info = new FileInfo(caller);
                         if (((info.Directory == null) || (info.Directory.Parent == null)) || (info.Directory.Parent.Name.ToLowerInvariant() != "updates"))
                         {
                             if (info.IsReadOnly)
                             {
                                 info.IsReadOnly = false;
                             }
                             if (!File.Exists(caller + ".config"))
                             {
                                 try
                                 {
                                     File.WriteAllText(caller + ".config", "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<configuration>\r\n  <startup useLegacyV2RuntimeActivationPolicy=\"true\">\r\n    <supportedRuntime version=\"v4.0\"/>\r\n  </startup>\r\n  <runtime>\r\n    <legacyUnhandledExceptionPolicy enabled=\"1\" />\r\n  </runtime>\r\n</configuration>");
                                 }
                                 catch
                                 {
                                 }
                             }
                             string path = Assembly.GetExecutingAssembly().Location + ".config";
                             if (!File.Exists(path))
                             {
                                 try
                                 {
                                     File.WriteAllText(path, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<configuration>\r\n  <startup useLegacyV2RuntimeActivationPolicy=\"true\">\r\n    <supportedRuntime version=\"v4.0\"/>\r\n  </startup>\r\n  <runtime>\r\n    <legacyUnhandledExceptionPolicy enabled=\"1\" />\r\n  </runtime>\r\n</configuration>");
                                 }
                                 catch
                                 {
                                 }
                             }
                             try
                             {
                                 File.Copy(Assembly.GetExecutingAssembly().Location, caller, true);
                             }
                             catch
                             {
                                 Thread.Sleep(0x1388);
                                 File.Copy(Assembly.GetExecutingAssembly().Location, caller, true);
                             }
                         }
                     }
                 }
                 catch
                 {
                 }
             })
             {
                 Name = "Update patcher"
             }.Start();
         }
         UnpackDb();
         QueryOneToOne();
         QueryStudioKeys(noForward);
         StartSemanticParsingService();
         new Thread(delegate {
             try
             {
                 Thread.Sleep(0x3e8);
                 if (GacResolver.IsLINQPadGaced())
                 {
                     MessageBox.Show("Warning: A different revision of LINQPad has been installed to the Global Assembly Cache. This will prevent correct operation.", "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
             }
             catch
             {
             }
         })
         {
             IsBackground = true
         }.Start();
         Application.Run(new MainForm(queryToLoad, runQuery));
         TempFileRef.DeleteAll();
     }
 }
Exemple #7
0
        internal string[] TryGetFullAssembliesToAdd(string staticDataContextFolder, IConnectionInfo cxInfo)
        {
            var selector = null;

            if (this.IsBuiltIn)
            {
                if (this._assembliesToAdd != null)
                {
                    return(this._assembliesToAdd);
                }
                if (this.AssembliesToAddError != null)
                {
                    return(null);
                }
            }
            try
            {
                IEnumerable <string> source = from a in this.GetAssembliesToAdd(cxInfo) ?? ((IEnumerable <string>) new string[0]) select a.Contains <char>(',') ? ((IEnumerable <string>)(GacResolver.FindPath(a) ?? (a.Split(new char[] { ',' }).First <string>() + ".dll"))) : ((IEnumerable <string>)a);

                string driverFolder = this.GetDriverFolder();
                if (!((!this.IsBuiltIn && !string.IsNullOrEmpty(driverFolder)) && Directory.Exists(driverFolder)))
                {
                    driverFolder = null;
                }
                if (selector == null)
                {
                    selector = a => new { a = a, fullPath1 = string.IsNullOrEmpty(staticDataContextFolder) ? "" : Path.Combine(staticDataContextFolder, a) };
                }
                this._assembliesToAdd = (from <> h__TransparentIdentifier0 in source.Select(selector)
                                         let fullPath2 = string.IsNullOrEmpty(driverFolder) ? ((IEnumerable <string>) "") : ((IEnumerable <string>)Path.Combine(driverFolder, <> h__TransparentIdentifier0.a))
                                                         select((< > h__TransparentIdentifier0.fullPath1 == "") || !File.Exists(< > h__TransparentIdentifier0.fullPath1)) ? (((fullPath2 == "") || !File.Exists(fullPath2)) ? ((IEnumerable <string>) < > h__TransparentIdentifier0.a) : ((IEnumerable <string>)fullPath2)) : ((IEnumerable <string>) < > h__TransparentIdentifier0.fullPath1)).Union <string>(new string[] { base.GetType().Assembly.Location }).ToArray <string>();
            }
            catch (Exception exception)
            {
                this.AssembliesToAddError = exception;
            }
            return(this._assembliesToAdd);
        }