Reading assembly versionnumber without locking the file

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top