1
我無法使用OTP .NET庫在Windows Server 2012計算機上從Powershell查詢Oracle。無法使用Powershell爲Oracle加載文件或程序集
我下載ODP.NET_Managed_ODAC12cR4.zip與
install_odpm.bat c:\oracle x64 false
在我沒有安裝Oracle的服務器上安裝。
這條線:
Add-Type -Path "C:/oracle/odp.net/managed/common/Oracle.ManagedDataAccess.dll"
或該行:
[System.Reflection.Assembly]::LoadFrom("C:/oracle/odp.net/managed/common/Oracle.ManagedDataAccess.dll")
兩個給我下面的錯誤:
PS C:\temp> .\impoinftel.ps1
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or
assembly
'file:///C:\oracle\odp.net\managed\common\Oracle.ManagedDataAccess33.dll' or
one of its dependencies. The system cannot find the file specified."
At C:\temp\impoinftel.ps1:2 char:1
+ [System.Reflection.Assembly]::LoadFrom("C:/oracle/odp.net/managed/common/Orac
le. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileNotFoundException
New-Object : Cannot find type
[Oracle.ManagedDataAccess.Client.OracleConnection]: make sure the assembly
containing this type is loaded.
At C:\temp\impoinftel.ps1:4 char:9
+ $con = New-Object Oracle.ManagedDataAccess.Client.OracleConnection("User
Id=byb ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentExcepti
on
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewOb
jectCommand
vcredist_x64.exe安裝在我的服務器
上powershell.exe.c onfig如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
</configuration>