diff --git a/Base/Base.vbproj b/Base/Base.vbproj index 5dfb5f21..af2f05e0 100644 --- a/Base/Base.vbproj +++ b/Base/Base.vbproj @@ -75,7 +75,7 @@ - + @@ -95,6 +95,7 @@ Settings.settings True + diff --git a/Base/ECM.vb b/Base/ECM/ECM.vb similarity index 100% rename from Base/ECM.vb rename to Base/ECM/ECM.vb diff --git a/Base/Performance.vb b/Base/Performance.vb new file mode 100644 index 00000000..f94d50a6 --- /dev/null +++ b/Base/Performance.vb @@ -0,0 +1,44 @@ +Imports System.IO +Imports System.Reflection +Imports System.Runtime.InteropServices +Imports System.Security.Cryptography +Imports DigitalData.Modules.Logging + +Public Class Performance + Public Sub New(pLogConfig As LogConfig, pAppDataPath As String) + Dim savedHash = String.Empty + Dim assemblyLocation = Assembly.GetEntryAssembly().Location + + Dim hashPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "hash.txt") + If Not File.Exists(hashPath) Then + File.Create(hashPath) + Else + savedHash = File.ReadAllText(hashPath) + End If + + Dim hash = String.Concat(SHA1.Create().ComputeHash(File.ReadAllBytes(assemblyLocation)).Select(Function(x) x.ToString("x2"))) + If hash.Equals(savedHash) Then + Return + End If + + Dim dotNetRuntimePath = RuntimeEnvironment.GetRuntimeDirectory() + Dim ngenPath = Path.Combine(dotNetRuntimePath, "ngen.exe") + + Dim process = New Process With { + .StartInfo = New ProcessStartInfo With { + .FileName = ngenPath, + .Arguments = $"install ""{assemblyLocation}"" /nologo", + .CreateNoWindow = True, + .UseShellExecute = True, + .Verb = "runas" + } + } + Try + process.Start() + process.WaitForExit() + File.WriteAllText(hashPath, hash) + Catch + ' ... + End Try + End Sub +End Class