【发布时间】:2022-01-12 22:09:16
【问题描述】:
我正在尝试在 VS Code 中安装上述软件包。出于某种原因,当我将它放在脚本的顶部时,我收到一条错误消息。
using namespace system.collections.generic
Add-Type -AssemblyName System.Data.OracleClient
Add-Type -Path "C:\Users\me\OneDrive - company\Documents\2021\temp endToEnd\oracle.ManagedDataAccess.Core\oracle.manageddataaccess.core.3.21.50\lib\netstandard2.1\Oracle.ManagedDataAccess.dll"
错误:
Add-Type : Missing an argument for parameter 'AssemblyName'. Specify a parameter of type 'System.String[]' and try again.
我也试过Add-type -Path "C:\Users\me\OneDrive - company\Documents\2021\temp endToEnd\oracle.ManagedDataAccess.Core\oracle.manageddataaccess.core.3.21.50\lib\netstandard2.1\Oracle.ManagedDataAccess.dll"
它有这个错误:
Add-Type : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
我的问题是,我该如何加载它,所以我可以执行以下操作:
$connectionString = "Data Source=$dataSource;User Id=$username;Password=$password;"
$con = New-Object Oracle.ManagedDataAccess.Client.OracleConnection($connectionString)
我正在尝试安装此软件包,因为当我尝试执行上面的最后一行代码时出现此错误:
New-Object : Cannot find type [Oracle.ManagedDataAccess.Client.OracleConnection]: verify that the assembly containing this type is loaded.
我也尝试通过 nuget manager 执行此操作,使用 ctrl shift P,nuget manager,但它没有出现在我可以看到的列表中(odp.net、oracle managed...等)。
我已经从 oracle 网站下载了这个:
oracle.manageddataaccess.core.3.21.50.nupkg
然后我使用 7-zip 将其解压缩到我要添加类型的位置。
我一直在查看这些链接: New-object Oracle.ManagedDataAccess.Client.OracleConnection
oracle-developer-tools-vs-code
install nuget package in vs code
我似乎无法安装此命令,因此该命令在脚本中有效。任何帮助将不胜感激。
【问题讨论】:
-
第一个技巧是下载正确的
Oracle.ManagedDataAccess.dll,一旦你有了它,那么add-type -path (join-path $DownloadedPath 'Oracle.ManagedDataAccess.dll')将在不安装oracle客户端的情况下工作。
标签: oracle powershell visual-studio-code package