powershell - Add-Type -ReferencedAssemblies fails with could not load or find assembly. Solution -


The solution to this problem adds DLL to GAC as suggested in one of the responses of my posting. As I mentioned in one of my responses, this process needs to be run where liberation in the environment will not be available. Because of this, the simple solution of unhygienic is not an option. To solve this, I've got a posh function that will add DLL to GAC:

Ultimate ([string] $ dllPath)

[string] $ publicToken = $ null [string ] $ Val = $ null [string] $ version = $ null

if (test-path) $ dllPath) {$ baseFileName = [System.IO.Path] :: GetFileName without extension ($ dllpath) $ TargetName = "C: \ windows \ assembly \ GAV_MSIL \" + $ baseFileName

  # key and public token $ val = sn -tp $ dllpath get # version w / o loading Is $ version = [System.reflection.AssemblyName] :: GetAssemblyName ($ dllPath) Version # Proceed if the token is valid ($ val -ne -null) {$ vals = $ val.split ("") $ publicToken = $ vals [$ Vals.length-1] $ targetNameSub = $ targetName + "\" + $ Version + "__" + $ public token if (! (Test-path $ targetName)) {Md $ targetName | Out-null} Md $ targetNameSub | Out-null # gcc copy-item $ dllpath $ targetNameSub | Copy DLL out-null}  

}

I have tested it and it works very well. In my research I found something that indicated that the registry keeps the entries for the registry which I am not doing. But this function works very well.

I tried to change the process of coming with the posh function to remove the GAC entries, but I have not succeeded so far until every DLL file is removed by getting the entry.

The problem seems like tools.Utilities.dll is itself fine But one if its reliance is not available inside c: \ Program Files \ subDir . This is both error message and the fact that the problem is solved by moving DLL to a different folder. It's likely that missing dependencies are available in new folders.

The easiest way to verify that loading is to use fuslogvw.exe to properly look at preventing tools.Utilities.dll .


Comments