mercredi 19 septembre 2018

Type search fails

I use PowerShell in version 5+ and I loaded external DLLs into the AppDomain of PS.

In the program I would like to compare types and to determine a Type, the System.Type.GetType method seems the right fit.

The script snapshot looks as follows:

[System.Reflection.Assembly]::LoadFile("..path..\Oracle.ManagedDataAccess.dll") | Out-Null
$Type = [System.Type]::GetType("Oracle.ManagedDataAccess.Client.OracleCommand", $true, $true)

But PowerShell throws an exception (roughly translated, not the original english message):

Exception while calling "GetType" with 3 arguments:  "The Type
"Oracle.ManagedDataAccess.Client.OracleCommand" in the assembly "Anonymously Hosted DynamicMethods 
Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" could not be load."
In script.ps1:2 Character:1
+ $Type = [System.Type]::GetType("Oracle.ManagedDataAccess.Client.Oracl ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : TypeLoadException

Is there a possibility to don't check in the 'Anonymously Hosted DynamicMethods Assembly' but to check the current loaded AppDomain space to find the Type specified?





Aucun commentaire:

Enregistrer un commentaire