Database Reference
In-Depth Information
There's more...
To discard the output of the assembly load, use either
[void]
or a pipe to
Out-Null
.
[System.Reflection.Assembly]::Load($odpAssemblyName) | Out-Null
[void][System.Reflection.Assembly]::Load($odpAssemblyName)
Alternatively, capture the output to a variable and format another way:
$odpAsm = [System.Reflection.Assembly]::Load($odpAssemblyName)
"Loaded Oracle.DataAccess from {0}" -f $odpAsm.Location
Here are three other ways of loading ODP.NET:
F
[Reflection.Assembly]::LoadWithPartialName("Oracle.DataAccess")
$filename = "C:\Oracle\product\11.2.0\client_1\odp.net\bin\2.x\
Oracle.DataAccess.dll"
F
[void][Reflection.Assembly]::LoadFile($filename)
F
[void][Reflection.Assembly]::LoadFrom($filename)
LoadWithPartialName
is convenient but blindly loads an unknown version of
ODP.NET
.
Both
LoadFile
and
LoadFrom
can also lead to issues. See
http://msdn.microsoft.
com/en-us/library/dd153782.aspx
for assembly loading best practices. Using
Load
with an explicit, full assembly identity is safest, despite more typing.
Now, let's ind out how to get help with
ODP.NET
, and some other ways of accessing Oracle.
Getting help with ODP.NET
Oracle's ODP documentation can be accessed via the Start Menu, with Windows Explorer
under
ORACLE_BASE\ORACLE_HOME\ODACDoc\DocumentationLibrary
, or
online at
http://docs.oracle.com
.
Also, PowerShell's
Get-Member
(alias
gm
) is useful for inspecting available members of
objects; for example, use
$conn | gm
to list all the properties and methods available
on the
OracleConnection
that was created.
Loading ODP.NET 4.0
The ODAC installation installs two versions of Oracle.DataAccess, one for .NET Framework
2 and another for PowerShell 2.0, which was built before .NET Framework 4.0. As such, you
cannot directly load Version 4.0 assemblies by default. Generally the Version 2.0 will sufice.
If there are speciic 4.0 features you want, you have a few options:
F
Change a global registry setting that forces all .NET 2.0 assemblies to run under .NET
4 (from PowerShell or otherwise); this has a number of serious consequences and
should almost always be avoided.
Search WWH ::
Custom Search