Add-Type -path" c:\ Oracle \ Oracle.ManagedDataAccess.dll"在Powershell失败了

时间:2012-12-17 18:18:47

标签: powershell oracle11g

我正在尝试按照this post for making an Oracle connection in PowerShell的说明进行操作。当我尝试加载Oracle .dll时,我得到一个不支持的操作错误。

PS C:\windows\system32> Add-Type -path "C:\Oracle\Oracle.ManagedDataAccess.dll"
Add-Type : Could not load file or assembly 'file:///C:\Oracle\Oracle.ManagedDataAccess.dll' or one of its dependencies.
 Operation is not supported. (Exception from HRESULT: 0x80131515)
At line:1 char:9
+ Add-Type <<<<  -path "C:\Oracle\Oracle.ManagedDataAccess.dll"
    + CategoryInfo          : NotSpecified: (:) [Add-Type], FileLoadException
    + FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand

2 个答案:

答案 0 :(得分:0)

你可以这样试试:

[System.Reflection.Assembly]::LoadFrom("C:\Oracle\Oracle.ManagedDataAccess.dll")

验证是否可以访问文件夹并解锁文件。

答案 1 :(得分:0)

通过在TNSNAMES.ORA中添加正确的条目并重新启动powershell来解决。