Reputation: 450
I am using PowerShell against Oracle with much success.
I am using the ODP Managed Provider. Since the provider can be installed in different locations, the Add-Type -Path
needs to point differently on different machines.
I would like to be able to refer to this assembly in a way that does not rely on full path to the DLL.
Upvotes: 1
Views: 520
Reputation: 450
I found this solution, which relies on knowing the strong name of the wanted assembly. It seems to work reliably on the testing that I have done
[void][reflection.assembly]::Load("Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342")
Upvotes: 1
Reputation: 23355
I think you could potentially get the install directory from the Registry with PowerShell. One possible location is here:
Get-ChildItem HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\odp.net.managed
Although that might vary depending on which .NET version is installed. You could try a wildcard for that:
Get-ChildItem HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\*\AssemblyFoldersEx\odp.net.managed
And ultimately you might need to get value of one of the properties of that registry key, for example if it's the '(default)' value:
(Get-ItemProperty HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\*\AssemblyFoldersEx\odp.net.managed).'(default)'
Upvotes: 0