The solution to this problem is add the DLLs to the GAC as was suggested in one of the responses to my posting. As I noted in one of my responses, the gacutility will not be available in the environment where this process needs to run. Because of this the simple solution of the gacutility is not an option. To resolve this I derived a Posh function that will add DLLs to the GAC:
param([string]$dllPath)
[string]$publicToken = $null [string]$val = $null [string]$version = $null
if (test-path) $dllPath) { $baseFileName = [System.IO.Path]::GetFileNameWithoutExtension($dllPath) $targetName = "c:\windows\assembly\GAV_MSIL\" + $baseFileName
# Get the key and public token
$val = sn -Tp $dllPath
# Get the version w/o loading
$version = [System.reflection.AssemblyName]::GetAssemblyName($dllPath).Version
# Proceed if the token is valid
if ($val -ne -null)
{
$vals = $val.split(" ")
$publicToken = $vals[$vals.length-1]
$targetNameSub=$targetName + "\" + $version + "__" + $publicToken
if (!(test-path $targetName))
{
Md $targetName | Out-Null
}
Md $targetNameSub | Out-Null
# Copy the DLL to the GAC
copy-item $dllPath $targetNameSub | Out-Null
}
}
I have tested this and it works very well. In my research I found something that indicated that the gacutility makes entries to the registry which I am not doing. But this function does work quite well.
I have tried to reverse the process to come up with a Posh function to remove the GAC entries but I have not been successful yet each time getting an access denied on the DLL file removal.