Skip to content

Navigation Menu

Sign in
Sign up

Error on connecting with Open-MySqlConnection #151

Unanswered
Myjestic asked this question in Q&A
Discussion options

Hi,
I just installed the newest version 2.0.2.70 on Powershell Core 7.4.2.

This is my connection script to MariaDB:
$c = [pscredential]::new($dbUser, (ConvertTo-SecureString -Force -AsPlainText $dbPass)) Open-MySqlConnection -connectionname 'MariaDB' -Server $dbHost -Database $dbName -Credential $c $testconnection = Test-SqlConnection -ConnectionName 'MariaDB' Write-Host $testconnection

Dot Net installed:
ComputerName : localhost

=4.x : 4.8+
v4\Client : Installed
v4\Full : Installed
v3.5 : Installed
v3.0 : Installed
v2.0.50727 : Installed
v1.1.4322 : Not installed (no key)

And that is the error I get:
Could not load type 'Oracle.ManagedDataAccess.Client.OracleDBAPrivilege' from assembly | 'Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342'.

How can I solve this issue? What is the reason?

You must be logged in to vote

Replies: 2 comments 12 replies

Comment options

@Myjestic -- you are launch pwsh and importing the module and then trying to open a connection, correct? i.e. you are using the standard powershell 7 host and not a custom host?

You must be logged in to vote
2 replies
Comment options

Hello @mithrandyr,
I'm using Powershell Core 7.4.2 on Windows Server 2019. I installed SimplySQL with -scope AllUsers. I'm using the default host.
I got it working an hour ago. I'll explain what the reason is and what my workaround was.
I just found out that I have a second Oracle.ManagedDataAccess.dll in the following location. C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Oracle.ManagedDataAccess\v4.0_4.122.1.0__89b483f429c47342\Oracle.ManagedDataAccess.dll

If I rename this DLL to _Oracle.ManagedDataAccess.dll and open the powershell again, your module works like a charm as it now loads the Oracle.ManagedDataAccess.dll from the SimplySQL structure.

I may have some apps that need the renamed DLL. However, this may only be a temporary workaround. I tried unloading existing assemblies and then importing SimplySql, but everything I tried was unsuccessful. I think this is because the assembly is loaded when the Powershell CLI starts.

Maybe you can find a solution for this setup.

Best regards.

Comment options

@Myjestic -- yeah, a DLL in the global cache could be a problem, but it shouldn't. I think I may an issue in assembly loading logic and in how the module is structured. Ideally, everything that is related to the providers, should be in a Assembly Load Context and therefore completely isolated (thus, when my module needs something, it only interacts with my packaged DLLs). However, this is not happening now, what is particularly weird is that you are using the MySql provider but the issue arises with the Oracle provider DLL. I'm going to do some additional digging. Thanks for bringing this to my attention!

Comment options

@Myjestic -- Have you tried the latest release of SimplySql? As far as I can tell, I've fixed the issue where other providers were loading when they didn't need to.

You must be logged in to vote
10 replies
Comment options

$PSVersionTable

you will want to look closely at the error stack $error for more details. The fact that it says "the assembly architecture is not compatible with the current process architecture" suggests that something is off. is this an ARM machine?

Comment options

$PSVersionTable

you will want to look closely at the error stack $error for more details. The fact that it says "the assembly architecture is not compatible with the current process architecture" suggests that something is off. is this an ARM machine?

Did you read my last message?

Comment options

apologies -- the module is not compiled against ARM architectures -- you could put in a request (issue, enhancement) for this and I can look into it. sorry for the confusion.

Comment options

Yeah I thought that might be the reason. I probably switch to the .NET connector for now.
I opened a feature request as advised #175 but I saw you already got one for the new Apple chips #173. Although I am running on Windows I would assume that could be solved the same way.

Comment options

@magic-happenz -- ARM support has been added for OSX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /