R
Roberto M. Oliva
hello all!
I am trying to do an update service for the executable of my application. I
download the new file and compare the versions of both assemblies using the
next code:
Dim new_assembly As System.Reflection.Assembly
Dim old_assembly As System.Reflection.Assembly
Dim new_build As Integer
Dim old_build As Integer
new_assembly = System.Reflection.Assembly.LoadFrom(strPathNew)
old_assembly = System.Reflection.Assembly.LoadFrom(strPathOld)
new_build = new_assembly.GetName().Version.Build
old_build = old_assembly.GetName().Version.Build
new_assembly = Nothing
old_assembly = Nothing
If (new_build > old_build) Then
' Delete the old one... and update to the new
System.IO.File.Delete(strPathOld)
System.IO.File.Move(strPathNew, strPathOld)
Else
' Delete the new one... the old remain
System.IO.File.Delete(strPathNew)
End If
strPathNew points to the recently downloaded executable and strPathOld
points to what was previously on the PDA.
Either I do a Move or a Delete I get an UnauthorizedAccessException error.
If I don't test the version of the assembly (I update to the new file
directly without testing versions, for example) everything works fine... so
I suspect there is something to do with the Assembly.LoadForm. But the file
remains loaded beyond the new_assembly = Nothing...
Can anybody tell me something? Any workaround?
Thanks a lot
Roberto
I am trying to do an update service for the executable of my application. I
download the new file and compare the versions of both assemblies using the
next code:
Dim new_assembly As System.Reflection.Assembly
Dim old_assembly As System.Reflection.Assembly
Dim new_build As Integer
Dim old_build As Integer
new_assembly = System.Reflection.Assembly.LoadFrom(strPathNew)
old_assembly = System.Reflection.Assembly.LoadFrom(strPathOld)
new_build = new_assembly.GetName().Version.Build
old_build = old_assembly.GetName().Version.Build
new_assembly = Nothing
old_assembly = Nothing
If (new_build > old_build) Then
' Delete the old one... and update to the new
System.IO.File.Delete(strPathOld)
System.IO.File.Move(strPathNew, strPathOld)
Else
' Delete the new one... the old remain
System.IO.File.Delete(strPathNew)
End If
strPathNew points to the recently downloaded executable and strPathOld
points to what was previously on the PDA.
Either I do a Move or a Delete I get an UnauthorizedAccessException error.
If I don't test the version of the assembly (I update to the new file
directly without testing versions, for example) everything works fine... so
I suspect there is something to do with the Assembly.LoadForm. But the file
remains loaded beyond the new_assembly = Nothing...
Can anybody tell me something? Any workaround?
Thanks a lot
Roberto