Tuesday, February 12, 2019

Assembly missing in PowerShell Core Cmdlet

I created a Visual Studio 2017 (community; OSX) "Class Library" project to experiment w/ Oracle's ODD.net provider.

Using NuGet, I installed the System.Management.Automation (for Core) (6.1.2) and Oracle.ManagedDataAccess.Core (2.18.3) packages.

I created the Cmdlet:

 using System; 

using System.Management.Automation; using Oracle.ManagedDataAccess.Client; using Oracle.ManagedDataAccess.Types;

namespace PsOracleCore.Cmdlets 

{

[Cmdlet(VerbsCommon.New, "Session")] 

[OutputType(typeof(OracleConnection))] public class NewSessionCmdlet : Cmdlet { [Parameter(Position = 0)] [ValidateNotNullOrEmpty] public string Account { get; set; }

[Parameter(Position = 1)] 

[ValidateNotNullOrEmpty] public string Password { get; set; }

[Parameter(Position = 2)] 

[ValidateNotNullOrEmpty] public string Server { get; set; }

 protected override void ProcessRecord() 

{ //base.ProcessRecord();

string connectionString = String.Format("User Id={0};Password={1};Data Source={2};",this.Account,this.Password,this.Server); OracleConnection connection = new OracleConnection(); 

connection.ConnectionString = connectionString; connection.Open();

WriteObject(connection); } } // class } // namespace 

Created the module's manifest:

@{ RootModule = 'PsOracleCore.dll' ... 

CmdletsToExport = @("New-Session") ... }

Opened a Terminal session, loaded pwsh, changed to the project's bin/Debug/netcoreapp2.1 directory, and imported the module:

import-module ./PsOracleCore.psd1 -force 

When I attempt to use the New-Session Cmdlet, I get an error:

PS> new-session Could not load file or assembly 'Oracle.ManagedDataAccess, Version=2.0.18.3, Culture=neutral, PublicKeyToken=89b483f429c47342'. The system cannot find the file specified. At line:1 char:1 + new-session + ~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [], FileNotFoundException + FullyQualifiedErrorId : System.IO.FileNotFoundException 

I've installed PowerShell Core:

PS> $psversiontable Name Value ---- ----- PSVersion 6.1.2 PSEdition Core GitCommitId 6.1.2 OS Darwin 18.2.0 Darwin Kernel Version 18.2.0: Thu Dec 20 ... Platform Unix PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0 

What am I missing? Is this an indication that Oracle's assembly isn't compatible w/ this version of PowerShell?

Assembly missing in PowerShell Core Cmdlet Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team