如何在Powershell中向ODP.Net托管驱动程序添加配置选项 [英] How to add configuration options to ODP.Net Managed Driver in Powershell
问题描述
使用Powershell中的Oracle托管数据提供程序ODP.NET效果很好.但是,如何添加应用程序特定的配置设置还不太清楚.
Using Oracle Managed Data Provider ODP.NET from Powershell works great. However, how to add application specific configuration settings is not quite clear.
这怎么办?
推荐答案
可以使用常规方法在app.config-file中指定配置设置.您只需要从powershell脚本中引用配置:
The configuration settings can be specified in a app.config-file in the normal way. You just need to refer to the config from the powershell script:
$configPath = "\\server1\share1\app_folder\app.config"
[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $configPath)
Add-Type -Path "C:\Oracle\ODP.NET\managed\common\Oracle.ManagedDataAccess.dll"
$con = New-Object Oracle.ManagedDataAccess.Client.OracleConnection("User Id=/;Data Source=db")
$con.open()
$con.close()
然后,配置文件可以包含提供程序支持的任何设置.这包括引用Oracle Wallet的可能性,因此无需在脚本中指定密码.
The config-file can then contain any setting supported by the provider. This includes the possibility of referring to a Oracle Wallet, so that no passwords need be specified in the script.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<oracle.manageddataaccess.client>
<version number="4.121.2.0">
<settings>
<setting name="WALLET_LOCATION" value="(SOURCE = (METHOD = FILE)(METHOD_DATA =(DIRECTORY = \\server1\share1\app_folder\wallet)))"/>
<setting name="SQLNET.WALLET_OVERRIDE" value="true"/>
</settings>
</version>
</oracle.manageddataaccess.client>
</configuration>
这篇关于如何在Powershell中向ODP.Net托管驱动程序添加配置选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!