mithrandyr / SimplySql

PowerShell module for querying various SQL databases
MIT License
202 stars 30 forks source link

Exception connecting to Oracle database #29

Closed thorstenkampe closed 4 years ago

thorstenkampe commented 4 years ago

Windows 10 PowerShell 7.1.0-preview.4

Import-Module -Name SimplySql

$param  = @{
    ServiceName = 'xepdb1'
    UserName    = 'sys'
    Password    = 'password'
}

Open-OracleConnection @param
WARNING: You are using -UserName and -Password, these options are deprecated and will be removed in the future.  Please consider using -Credential.

An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will exit.
Unhandled exception. System.TypeLoadException: Could not load type 'System.Security.Principal.WindowsImpersonationContext' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
   at OracleInternal.ConnectionPool.PoolManager`3.CreateNewPRThreadFunc(Object state)
   at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
   at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)
   at System.Threading.QueueUserWorkItemCallback.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
mithrandyr commented 4 years ago

@thorstenkampe -- This module doesn't currently support PowerShell Core (PowerShell 7 is still based on .NET Core). You can use the module in PowerShell 7 if you use the -UseWindowsPowerShell switch on Import-Module.

I'm in the process of doing a rewrite that is .NET Core compatible, but it takes time.

thorstenkampe commented 4 years ago

I've updated the Oracle DLL from here: https://www.nuget.org/packages/Oracle.ManagedDataAccess.Core . Now it works. I'm closing the issue.

thorstenkampe commented 4 years ago

Just a quick headsup: SimplySql seems to work pretty well on PowerShell Core - even on Linux (with the MSSQL Provider)