Home All Groups Group Topic Archive Search About

AppDomain Question--Second Request

Author
23 May 2006 9:33 PM
John Wright
I have the following code that creates a new appDomain and loads an exe
using reflection.  The problem I have is the exe file I pass in is still
locked by the application.  I have showcopyfiles = "true" and specified the
locations for the appDomain to use. The shadowfiles and the original file is
locked when I execute the command tmpAssm = .Load(strApplicationName).  Now
if I have shadowcopyfiles on, why would setting the assembly to the file
lock it?  Any help is appreciated.

John

Private tmpDomain As AppDomain

Public Function LoadProgram(ByVal strApplicationName As String, ByVal
strApplicationEntryPoint As String) As Form

Dim tmpAppDomain As New AppDomainSetup

Dim tmpAssm As Assembly

Dim strName() As String

Dim strVersion As String

tmpAppDomain.ApplicationBase = "d:\wzprograms"

tmpAppDomain.ShadowCopyFiles = "true"

tmpAppDomain.ShadowCopyDirectories = "d:\wzprograms"

tmpAppDomain.PrivateBinPath = "d:\wzprograms"

'set the cache path for shadow files

tmpAppDomain.CachePath = "d:\wzprograms\tmp"

tmpDomain = AppDomain.CreateDomain("Temp", AppDomain.CurrentDomain.Evidence,
tmpAppDomain)

With tmpDomain

'.ExecuteAssembly("D:\wzprograms\versioncheck.exe")

tmpAssm = .Load(strApplicationName)

'.ExecuteAssembly(strApplicationName)

End With

'Get the version of the program

strName = Split(tmpAssm.FullName.ToString, ",")

strVersion = strName(1)

'set up the form to display by calling the Entry Point for the program.

LoadProgram = tmpAssm.CreateInstance(strApplicationEntryPoint, True)

Dim extType As Type = tmpAssm.GetType(strApplicationEntryPoint)

Dim extInfo As MethodInfo = extType.GetMethod("SetProperties")

If extInfo Is Nothing Then

MsgBox("This program cannot be run in the framework.", MsgBoxStyle.Critical,
"Invalid Framework Program")

Exit Function

End If

Dim myParamArray() As Object = {12345}

extInfo.Invoke(LoadProgram, myParamArray)

LoadProgram.Name = ("Test")

LoadProgram.Text = "VersionCheck. " & strVersion

AppDomain.Unload(tmpDomain)

End Function

AddThis Social Bookmark Button