System.Data.SQLite
Check-in [4ef76f59b4]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:64-bit enhancements
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sourceforge
Files: files | file ages | folders
SHA1: 4ef76f59b4ca36c093d4826350b7c89d025ca73c
User & Date: rmsimpson 2006-04-12 05:48:31
Context
2006-04-12
21:11
LIBPATH fixes for external tools check-in: 2513e50f9b user: rmsimpson tags: sourceforge
05:48
64-bit enhancements check-in: 4ef76f59b4 user: rmsimpson tags: sourceforge
05:47
1.0.28.0 prep check-in: 49268d8c86 user: rmsimpson tags: sourceforge
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tools/install/InstallDesigner.cs.

13
14
15
16
17
18
19

20
21
22
23
24
25
26
...
269
270
271
272
273
274
275























































276
277
278
279
280
281
282
...
303
304
305
306
307
308
309


























310
311
312
313
314
315
316
...
336
337
338
339
340
341
342
343
344
345









346
347
348
349
350
351
352
...
472
473
474
475
476
477
478


















479
480
481
482
483
484
485
...
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
...
604
605
606
607
608
609
610









611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
  using System.Drawing;
  using System.Text;
  using System.Windows.Forms;
  using Microsoft.Win32;
  using System.IO;
  using System.GACManagedAccess;
  using System.Xml;


  public partial class InstallDesigner : Form
  {
    private static Guid standardDataProviderGuid = new Guid("{0EBAAB6E-CA80-4b4a-8DDF-CBE6BF058C70}");
    private static Guid standardDataSourcesGuid = new Guid("{0EBAAB6E-CA80-4b4a-8DDF-CBE6BF058C71}");
    private static Guid standardCFDataSourcesGuid = new Guid("{0EBAAB6E-CA80-4b4a-8DDF-CBE6BF058C72}");
    private static Guid oledbDataProviderGuid = new Guid("{7F041D59-D76A-44ed-9AA2-FBF6B0548B80}");
................................................................................
                {
                  subkey.SetValue(null, path);
                }
              }
            }
          }
        }























































      }
      else // No checkboxes are checked, remove some global settings
      {
        try
        {
          Registry.LocalMachine.DeleteSubKey("Software\\Microsoft\\.NETFramework\\v2.0.50727\\AssemblyFoldersEx\\SQLite");

................................................................................
                if (key != null) key.DeleteSubKey("SQLite");
              }
              catch
              {
              }
            }
          }


























        }
        catch
        {
        }
      }

      try
................................................................................
            if (String.IsNullOrEmpty(s)) break;

            AssemblyCache.UninstallAssembly(s, null, out disp);
          } SQLite = null;
        }
        else // Install SQLite into the GAC
        {

          AssemblyCache.InstallAssembly(SQLiteLocation, null, AssemblyCommitFlags.Default);
          AssemblyCache.InstallAssembly(Path.GetFullPath("SQLite.Designer.DLL"), null, AssemblyCommitFlags.Default);









        }
      }
      catch
      {
        throw;
      }
    }
................................................................................
          subkey.SetValue(null, "SQLite Database File");
          using (RegistryKey subsubkey = subkey.CreateSubKey("SupportingProviders", RegistryKeyPermissionCheck.ReadWriteSubTree))
          {
            subsubkey.CreateSubKey(provider.ToString("B")).Close();
          }
        }
      }



















      for (int n = 0; n < compactFrameworks.Length; n++)
      {
        using (RegistryKey key = Registry.LocalMachine.OpenSubKey(String.Format("Software\\Microsoft\\.NETCompactFramework\\v2.0.0.0\\{0}\\DataProviders", compactFrameworks[n]), true))
        {
          if (key != null)
          {
................................................................................
        using (RegistryKey subkey = key.CreateSubKey("{DCBE6C8D-0E57-4099-A183-98FF74C64D9D}", RegistryKeyPermissionCheck.ReadWriteSubTree))
        {
          subkey.SetValue(null, "{DCBE6C8D-0E57-4099-A183-98FF74C64D9C}");
          subkey.SetValue("Name", "SQLite Provider Object Factory");
        }
      }
#endif

      // We used to add factory support to the machine.config -- but its not desirable.
      // Now, we use the development environment's config file instead.
      string xmlFileName;
      XmlDocument xmlDoc = GetConfig(keyname, out xmlFileName);

      if (xmlDoc == null) return;

      XmlNode xmlNode = xmlDoc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"System.Data.SQLite\"]");
      if (xmlNode == null)
      {
        XmlNode xmlConfig = xmlDoc.SelectSingleNode("configuration");
        if (xmlConfig != null)
        {
          XmlNode xmlData = xmlConfig.SelectSingleNode("system.data");
          if (xmlData == null)
          {
            xmlData = xmlDoc.CreateNode(XmlNodeType.Element, "system.data", "");
            xmlConfig.AppendChild(xmlData);
          }
          XmlNode xmlParent = xmlData.SelectSingleNode("DbProviderFactories");
          if (xmlParent == null)
          {
            xmlParent = xmlDoc.CreateNode(XmlNodeType.Element, "DbProviderFactories", "");
            xmlData.AppendChild(xmlParent);
          }

          //xmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "remove", "");
          //xmlNode.Attributes.SetNamedItem(xmlDoc.CreateAttribute("invariant"));
          //xmlParent.AppendChild(xmlNode);
          //xmlNode.Attributes.GetNamedItem("invariant").Value = "System.Data.SQLite";

          xmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "add", "");
          xmlNode.Attributes.SetNamedItem(xmlDoc.CreateAttribute("name"));
          xmlNode.Attributes.SetNamedItem(xmlDoc.CreateAttribute("invariant"));
          xmlNode.Attributes.SetNamedItem(xmlDoc.CreateAttribute("description"));
          xmlNode.Attributes.SetNamedItem(xmlDoc.CreateAttribute("type"));
          xmlParent.AppendChild(xmlNode);
        }
      }
      xmlNode.Attributes.GetNamedItem("name").Value = "SQLite Data Provider";
      xmlNode.Attributes.GetNamedItem("invariant").Value = "System.Data.SQLite";
      xmlNode.Attributes.GetNamedItem("description").Value = ".Net Framework Data Provider for SQLite";
      xmlNode.Attributes.GetNamedItem("type").Value = "System.Data.SQLite.SQLiteFactory, " + SQLite.GetName().FullName;

      xmlDoc.Save(xmlFileName);
    }

    private XmlDocument GetConfig(string keyname, out string xmlFileName)
    {
      // xmlFileName = Environment.ExpandEnvironmentVariables("%WinDir%\\Microsoft.NET\\Framework\\v2.0.50727\\CONFIG\\machine.config");

      try
      {
        using (RegistryKey key = Registry.LocalMachine.OpenSubKey(String.Format("Software\\Microsoft\\{0}\\{1}", keyname, _regRoot), true))
        {
          xmlFileName = (string)key.GetValue("InstallDir");
          if (String.Compare(keyname, "VisualStudio", true) == 0)
            xmlFileName += "devenv.exe.config";
................................................................................
        {
          if (key != null) key.DeleteSubKeyTree(provider.ToString("B"));
        }
        using (RegistryKey key = Registry.LocalMachine.OpenSubKey(String.Format("Software\\Microsoft\\{0}\\{1}\\DataSources", keyname, _regRoot), true))
        {
          if (key != null) key.DeleteSubKeyTree(source.ToString("B"));
        }









      }
      catch
      {
      }

      // Remove factory support from the development environment config file
      string xmlFileName;
      XmlDocument xmlDoc = GetConfig(keyname, out xmlFileName);

      if (xmlDoc == null) return;

      XmlNode xmlNode = xmlDoc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"System.Data.SQLite\"]");
      if (xmlNode != null)
        xmlNode.ParentNode.RemoveChild(xmlNode);

      xmlNode = xmlDoc.SelectSingleNode("configuration/system.data/DbProviderFactories/remove[@invariant=\"System.Data.SQLite\"]");
      if (xmlNode != null)
        xmlNode.ParentNode.RemoveChild(xmlNode);

      xmlDoc.Save(xmlFileName);
      
      // Remove any entries in the machine.config if they're still there
      xmlFileName = Environment.ExpandEnvironmentVariables("%WinDir%\\Microsoft.NET\\Framework\\v2.0.50727\\CONFIG\\machine.config");
      xmlDoc = new XmlDocument();
      xmlDoc.PreserveWhitespace = true;
      xmlDoc.Load(xmlFileName);

      xmlNode = xmlDoc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"System.Data.SQLite\"]");
      
      if (xmlNode != null)
        xmlNode.ParentNode.RemoveChild(xmlNode);

      xmlNode = xmlDoc.SelectSingleNode("configuration/system.data/DbProviderFactories/remove[@invariant=\"System.Data.SQLite\"]");
      if (xmlNode != null)
        xmlNode.ParentNode.RemoveChild(xmlNode);








>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<


>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
<
<
<
<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


<
<







 







>
>
>
>
>
>
>
>
>












<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
...
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
...
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
...
418
419
420
421
422
423
424

425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
...
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
...
624
625
626
627
628
629
630
631




632










































633
634


635
636
637
638
639
640
641
...
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691

















692
693
694
695
696
697
698
  using System.Drawing;
  using System.Text;
  using System.Windows.Forms;
  using Microsoft.Win32;
  using System.IO;
  using System.GACManagedAccess;
  using System.Xml;
  using System.Diagnostics;

  public partial class InstallDesigner : Form
  {
    private static Guid standardDataProviderGuid = new Guid("{0EBAAB6E-CA80-4b4a-8DDF-CBE6BF058C70}");
    private static Guid standardDataSourcesGuid = new Guid("{0EBAAB6E-CA80-4b4a-8DDF-CBE6BF058C71}");
    private static Guid standardCFDataSourcesGuid = new Guid("{0EBAAB6E-CA80-4b4a-8DDF-CBE6BF058C72}");
    private static Guid oledbDataProviderGuid = new Guid("{7F041D59-D76A-44ed-9AA2-FBF6B0548B80}");
................................................................................
                {
                  subkey.SetValue(null, path);
                }
              }
            }
          }
        }

        for (int n = 0; n < 2; n++)
        {
          // Add factory support to the machine.config file.
          try
          {
            string xmlFileName = Environment.ExpandEnvironmentVariables(String.Format("%WinDir%\\Microsoft.NET\\{0}\\v2.0.50727\\CONFIG\\machine.config", (n == 0) ? "Framework" : "Framework64"));
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.PreserveWhitespace = true;
            xmlDoc.Load(xmlFileName);


            XmlNode xmlNode = xmlDoc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"System.Data.SQLite\"]");
            if (xmlNode == null)
            {
              XmlNode xmlConfig = xmlDoc.SelectSingleNode("configuration");
              if (xmlConfig != null)
              {
                XmlNode xmlData = xmlConfig.SelectSingleNode("system.data");
                if (xmlData == null)
                {
                  xmlData = xmlDoc.CreateNode(XmlNodeType.Element, "system.data", "");
                  xmlConfig.AppendChild(xmlData);
                }
                XmlNode xmlParent = xmlData.SelectSingleNode("DbProviderFactories");
                if (xmlParent == null)
                {
                  xmlParent = xmlDoc.CreateNode(XmlNodeType.Element, "DbProviderFactories", "");
                  xmlData.AppendChild(xmlParent);
                }

                //xmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "remove", "");
                //xmlNode.Attributes.SetNamedItem(xmlDoc.CreateAttribute("invariant"));
                //xmlParent.AppendChild(xmlNode);
                //xmlNode.Attributes.GetNamedItem("invariant").Value = "System.Data.SQLite";

                xmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "add", "");
                xmlNode.Attributes.SetNamedItem(xmlDoc.CreateAttribute("name"));
                xmlNode.Attributes.SetNamedItem(xmlDoc.CreateAttribute("invariant"));
                xmlNode.Attributes.SetNamedItem(xmlDoc.CreateAttribute("description"));
                xmlNode.Attributes.SetNamedItem(xmlDoc.CreateAttribute("type"));
                xmlParent.AppendChild(xmlNode);
              }
            }
            xmlNode.Attributes.GetNamedItem("name").Value = "SQLite Data Provider";
            xmlNode.Attributes.GetNamedItem("invariant").Value = "System.Data.SQLite";
            xmlNode.Attributes.GetNamedItem("description").Value = ".Net Framework Data Provider for SQLite";
            xmlNode.Attributes.GetNamedItem("type").Value = "System.Data.SQLite.SQLiteFactory, " + SQLite.GetName().FullName;

            xmlDoc.Save(xmlFileName);
          }
          catch
          {
          }
        }
      }
      else // No checkboxes are checked, remove some global settings
      {
        try
        {
          Registry.LocalMachine.DeleteSubKey("Software\\Microsoft\\.NETFramework\\v2.0.50727\\AssemblyFoldersEx\\SQLite");

................................................................................
                if (key != null) key.DeleteSubKey("SQLite");
              }
              catch
              {
              }
            }
          }

          for (int n = 0; n < 2; n++)
          {
            try
            {
              // Remove any entries in the machine.config if they're still there
              string xmlFileName = Environment.ExpandEnvironmentVariables(String.Format("%WinDir%\\Microsoft.NET\\{0}\\v2.0.50727\\CONFIG\\machine.config", (n == 0) ? "Framework" : "Framework64"));
              XmlDocument xmlDoc = new XmlDocument();
              xmlDoc.PreserveWhitespace = true;
              xmlDoc.Load(xmlFileName);

              XmlNode xmlNode = xmlDoc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"System.Data.SQLite\"]");

              if (xmlNode != null)
                xmlNode.ParentNode.RemoveChild(xmlNode);

              xmlNode = xmlDoc.SelectSingleNode("configuration/system.data/DbProviderFactories/remove[@invariant=\"System.Data.SQLite\"]");
              if (xmlNode != null)
                xmlNode.ParentNode.RemoveChild(xmlNode);

              xmlDoc.Save(xmlFileName);
            }
            catch
            {
            }
          }
        }
        catch
        {
        }
      }

      try
................................................................................
            if (String.IsNullOrEmpty(s)) break;

            AssemblyCache.UninstallAssembly(s, null, out disp);
          } SQLite = null;
        }
        else // Install SQLite into the GAC
        {

          AssemblyCache.InstallAssembly(SQLiteLocation, null, AssemblyCommitFlags.Default);
          AssemblyCache.InstallAssembly(Path.GetFullPath("SQLite.Designer.DLL"), null, AssemblyCommitFlags.Default);

          try
          {
            AssemblyCache.InstallAssembly(Path.Combine(Path.GetDirectoryName(SQLiteLocation), "x64\\System.Data.SQLite.DLL"), null, AssemblyCommitFlags.Default);
            AssemblyCache.InstallAssembly(Path.Combine(Path.GetDirectoryName(SQLiteLocation), "itanium\\System.Data.SQLite.DLL"), null, AssemblyCommitFlags.Default);
          }
          catch
          {
          }
        }
      }
      catch
      {
        throw;
      }
    }
................................................................................
          subkey.SetValue(null, "SQLite Database File");
          using (RegistryKey subsubkey = subkey.CreateSubKey("SupportingProviders", RegistryKeyPermissionCheck.ReadWriteSubTree))
          {
            subsubkey.CreateSubKey(provider.ToString("B")).Close();
          }
        }
      }

      //try
      //{
      //  using (RegistryKey key = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", true))
      //  {
      //    string libpath = (string)key.GetValue("LIB");
      //    string path = Path.GetDirectoryName(SQLiteLocation);

      //    if (libpath.IndexOf(path, StringComparison.InvariantCultureIgnoreCase) == -1)
      //    {
      //      libpath += (";" + path);
      //      key.SetValue("LIB", libpath);
      //    }
      //  }
      //}
      //catch
      //{
      //}

      for (int n = 0; n < compactFrameworks.Length; n++)
      {
        using (RegistryKey key = Registry.LocalMachine.OpenSubKey(String.Format("Software\\Microsoft\\.NETCompactFramework\\v2.0.0.0\\{0}\\DataProviders", compactFrameworks[n]), true))
        {
          if (key != null)
          {
................................................................................
        using (RegistryKey subkey = key.CreateSubKey("{DCBE6C8D-0E57-4099-A183-98FF74C64D9D}", RegistryKeyPermissionCheck.ReadWriteSubTree))
        {
          subkey.SetValue(null, "{DCBE6C8D-0E57-4099-A183-98FF74C64D9C}");
          subkey.SetValue("Name", "SQLite Provider Object Factory");
        }
      }
#endif
    }















































    private XmlDocument GetConfig(string keyname, out string xmlFileName)
    {


      try
      {
        using (RegistryKey key = Registry.LocalMachine.OpenSubKey(String.Format("Software\\Microsoft\\{0}\\{1}", keyname, _regRoot), true))
        {
          xmlFileName = (string)key.GetValue("InstallDir");
          if (String.Compare(keyname, "VisualStudio", true) == 0)
            xmlFileName += "devenv.exe.config";
................................................................................
        {
          if (key != null) key.DeleteSubKeyTree(provider.ToString("B"));
        }
        using (RegistryKey key = Registry.LocalMachine.OpenSubKey(String.Format("Software\\Microsoft\\{0}\\{1}\\DataSources", keyname, _regRoot), true))
        {
          if (key != null) key.DeleteSubKeyTree(source.ToString("B"));
        }

        //using (RegistryKey key = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", true))
        //{
        //  string libpath = (string)key.GetValue("LIB");
        //  string path = ";" + Path.GetDirectoryName(SQLiteLocation);

        //  libpath = libpath.Replace(path, "");
        //  key.SetValue("LIB", libpath);
        //}
      }
      catch
      {
      }

      // Remove factory support from the development environment config file
      string xmlFileName;
      XmlDocument xmlDoc = GetConfig(keyname, out xmlFileName);

      if (xmlDoc == null) return;

      XmlNode xmlNode = xmlDoc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"System.Data.SQLite\"]");

















      if (xmlNode != null)
        xmlNode.ParentNode.RemoveChild(xmlNode);

      xmlNode = xmlDoc.SelectSingleNode("configuration/system.data/DbProviderFactories/remove[@invariant=\"System.Data.SQLite\"]");
      if (xmlNode != null)
        xmlNode.ParentNode.RemoveChild(xmlNode);

Changes to tools/install/install.csproj.

35
36
37
38
39
40
41
42


43
44
45
46
47
48
49
    <Reference Include="System.Data" />
    <Reference Include="System.Deployment" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="GACWrap.cs" />


    <Compile Include="InstallDesigner.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="InstallDesigner.Designer.cs">
      <DependentUpon>InstallDesigner.cs</DependentUpon>
    </Compile>
    <Compile Include="Program.cs" />







|
>
>







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
    <Reference Include="System.Data" />
    <Reference Include="System.Deployment" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="GACWrap.cs">
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="InstallDesigner.cs">
      <SubType>Form</SubType>
    </Compile>
    <Compile Include="InstallDesigner.Designer.cs">
      <DependentUpon>InstallDesigner.cs</DependentUpon>
    </Compile>
    <Compile Include="Program.cs" />