我使用Add-Type加载了一个程序集:
$Typename = '\\crtwfaadvlkv0.d2dbfg.com\PRODUCTION\Vision\Apps\VisionPipeline\Oracle.ManagedDataAccess.dll'
Add-Type -LiteralPath $TypeName
并确认它已被加载
> [appdomain]::CurrentDomain.GetAssemblies() |
>> Sort-Object -Property FullName |
>> Select-Object -Property FullName;
(partial results)
Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342
下一步,我希望能够加载程序集中定义的类,以便使用它们,但是这会导致错误:
> $oracletpe = Add-Type -AssemblyName 'Oracle.ManagedDataAccess' -PassThru
Add-Type : Cannot add type. The assembly 'Oracle.ManagedDataAccess' could not be found.
At line:1 char:14
+ ... oracletpe = Add-Type -AssemblyName 'Oracle.ManagedDataAccess' -PassTh ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Oracle.ManagedDataAccess:String) [Add-Type], Exception
+ FullyQualifiedErrorId : ASSEMBLY_NOT_FOUND,Microsoft.PowerShell.Commands.AddTypeCommand
Add-Type : Cannot add type. One or more required assemblies are missing.
At line:1 char:14
+ ... oracletpe = Add-Type -AssemblyName 'Oracle.ManagedDataAccess' -PassTh ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-Type], InvalidOperationException
+ FullyQualifiedErrorId : ASSEMBLY_LOAD_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand
看起来PowerShell找不到刚刚加载的程序集。我做错了什么吗?