J
Johan Karlsson
Hi,
I'm trying to read an assembly versionnumber without locking the file. I
created a new AppDomain, turned shadowcopy on and even read the assembly
into a byte array before loading it. It still locks the file on disk though?
The assembly is in the same directory as the executable and is called
ICareClient.dll.
Thanks in advance
Johan
Sloppy Example Code:
Dim info As New AppDomainSetup
info.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory
info.PrivateBinPath = AppDomain.CurrentDomain.BaseDirectory
info.ShadowCopyDirectories = AppDomain.CurrentDomain.BaseDirectory
info.ShadowCopyFiles = "true"
Dim appD As AppDomain = AppDomain.CreateDomain("myDomain",
AppDomain.CurrentDomain.Evidence, info)
Dim app As [Assembly]
Dim f As New FileInfo("ICareClient.dll")
Dim fs As FileStream = f.OpenRead
Dim bytes As Byte()
ReDim bytes(fs.Length)
fs.Read(bytes, 0, fs.Length)
fs.Close()
Dim v As String
app = appD.Load(bytes)
v = app.GetName.Version.ToString
AppDomain.Unload(appD)
Return v
I'm trying to read an assembly versionnumber without locking the file. I
created a new AppDomain, turned shadowcopy on and even read the assembly
into a byte array before loading it. It still locks the file on disk though?
The assembly is in the same directory as the executable and is called
ICareClient.dll.
Thanks in advance
Johan
Sloppy Example Code:
Dim info As New AppDomainSetup
info.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory
info.PrivateBinPath = AppDomain.CurrentDomain.BaseDirectory
info.ShadowCopyDirectories = AppDomain.CurrentDomain.BaseDirectory
info.ShadowCopyFiles = "true"
Dim appD As AppDomain = AppDomain.CreateDomain("myDomain",
AppDomain.CurrentDomain.Evidence, info)
Dim app As [Assembly]
Dim f As New FileInfo("ICareClient.dll")
Dim fs As FileStream = f.OpenRead
Dim bytes As Byte()
ReDim bytes(fs.Length)
fs.Read(bytes, 0, fs.Length)
fs.Close()
Dim v As String
app = appD.Load(bytes)
v = app.GetName.Version.ToString
AppDomain.Unload(appD)
Return v