1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
Imports System
Imports System.IO
Namespace ShadowCopy
Class Program
<LoaderOptimization(LoaderOptimization.MultiDomainHost)> _
<STAThread> _
Public Shared Sub Main(args As String())
' Shadow-Copying ermöglichen:
Dim environmentPath As String = Environment.CurrentDirectory
Dim cachePath As String = Path.Combine(environmentPath, "__cache")
Dim configFile As String = Path.Combine(environmentPath, "Anwendung.exe.config")
Dim assembly As String = Path.Combine(environmentPath, "Anwendung.exe")
' Anwendungsdomänen-Setup ertellen:
Dim setup As New AppDomainSetup()
setup.ApplicationName = "Anwendung"
setup.ShadowCopyFiles = "true"
setup.CachePath = cachePath
setup.ConfigurationFile = configFile
' Anwendungsdomäne erstellen:
Dim domain As AppDomain = AppDomain.CreateDomain("Beispiel", AppDomain.CurrentDomain.Evidence, setup)
' Anwendung starten:
domain.ExecuteAssembly(assembly)
' Cache bereinigen:
AppDomain.Unload(domain)
Directory.Delete(cachePath, True)
End Sub
End Class
End Namespace
|