PhreeqcUsers Discussion Forum

Please email phreeqcusers at gmail.com with your name and affiliation to request an account.
Welcome Guest
 

  • Forum Home
  • Login
  • Register

  • PhreeqcUsers Discussion Forum »
  • Beginners »
  • Installation questions »
  • PHREEQC COM: 'A dynamic link library (DLL) initialization routine failed.'
« previous next »
  • Print
Pages: [1]   Go Down

Author Topic: PHREEQC COM: 'A dynamic link library (DLL) initialization routine failed.'  (Read 16916 times)

Leonardo

  • Contributor
  • Posts: 8
PHREEQC COM: 'A dynamic link library (DLL) initialization routine failed.'
« on: 26/02/24 04:34 »
Hi there,
I've been using PHREEQC COM for ~8 years now, from Python, on different computers. But most recently I changed my laptop and ran my previous scripts to find an error as follows:
Quote
Traceback (most recent call last):

  File ~\anaconda3\Lib\site-packages\win32com\client\dynamic.py:84 in _GetGoodDispatch
    IDispatch = pythoncom.connect(IDispatch)

com_error: (-2147221021, 'Operation unavailable', None, None)


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File ~\anaconda3\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File c:\mp4 geochemical assessment\4-working\5-modelling\frim\untitled0.py:10
    dbase = Dispatch('IPhreeqcCOM.Object')

  File ~\anaconda3\Lib\site-packages\win32com\client\__init__.py:118 in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx)

  File ~\anaconda3\Lib\site-packages\win32com\client\dynamic.py:104 in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)

  File ~\anaconda3\Lib\site-packages\win32com\client\dynamic.py:86 in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(

com_error: (-2147023782, 'A dynamic link library (DLL) initialization routine failed.', None, None)

The code is the following, and it crashes in the second line (Dispatch)

Quote
from win32com.client import Dispatch
dbase = Dispatch('IPhreeqcCOM.Object')
db_path = '1-database/WATEQ4F.DAT'
dbase.LoadDatabase(db_path)


I made a fresh install for everything (Anaconda- Python, and IPHREEQCCOM 3.73 x64 and x32). I also tried updating-reinstalling-uninstalling the win32 python library and tried it with other commands (works ok). And of course repair-reinstall for both x64 and x32 msi files for Iphreeqccom.
Nothing seems to fix the issue and I'm running out of options. The only difference I can tell from my previous computers is that this one has Windows 11 installed. Has anyone experienced this error?

Anyway, is not that terrible, maybe it's time to use PhreeqPy

Cheers!


« Last Edit: 17/04/24 03:41 by Leonardo »
Logged

charlton

  • Top Contributor
  • Posts: 50
Re: PHREEQC COM: 'A dynamic link library (DLL) initialization routine failed.'
« Reply #1 on: 27/02/24 01:17 »
Hi, my best guess is that a dll that the phreeqccom dll requires is missing from windows 11.  I don't currently have a windows 11 machine to test this on.  As soon as I can test it I'll let you know.

Scott
Logged

charlton

  • Top Contributor
  • Posts: 50
Re: PHREEQC COM: 'A dynamic link library (DLL) initialization routine failed.'
« Reply #2 on: 27/02/24 03:31 »
I was able to test on a windows 11 virtual machine and I think I found the problem.  When IPhreeqcCOM is installed it checks to make sure the .NET framework is installed.  Windows 11 (and possibly Windows 10) reports that the .NET framework is installed during the IPhreeqcCOM installation but it really isn't and is supposed to display a .NET installation the first time you attempt to use IPhreeqcCOM.  For some reason the .NET installation window is not shown when running in python.

Probably, the easiest solution is to attempt to instantiate a IPhreeqcCOM from within a powershell command prompt:

  type pwsh in the search bar and select the PowerShell 7 app

  type
     
Code: [Select]
$com = New-Object -ComObject IPhreeqcCOM.Object
  in the command prompt and it should display a dialog to install .NET Framework 3.5.

I'm not sure pwsh is installed by default on Windows 11 but I think it is.  Otherwise, you could search the Microsoft website for the .NET Framework 3.5 installer (or possibly use the Windows Features functionality within Windows itself to install it).

You might want to reboot windows before trying this in case the installer window has been hidden.

Let me know if this helps.
Scott


Logged

charlton

  • Top Contributor
  • Posts: 50
Re: PHREEQC COM: 'A dynamic link library (DLL) initialization routine failed.'
« Reply #3 on: 27/02/24 16:47 »
I created a gist to install .NET 3.5 on Windows 11:

https://gist.github.com/scharlton2/b8dd1ccd2820c62859c8e7ac5d1ccc2e
Logged

Leonardo

  • Contributor
  • Posts: 8
Re: PHREEQC COM: 'A dynamic link library (DLL) initialization routine failed.'
« Reply #4 on: 27/02/24 21:06 »

Thanks, Scott.

I ran a preliminary test (just trying the line dbase = Dispatch('IPhreeqcCOM.Object')) and it's working. Thank you so much for your impressively quick reply.

Cheers
Logged

charlton

  • Top Contributor
  • Posts: 50
Re: PHREEQC COM: 'A dynamic link library (DLL) initialization routine failed.'
« Reply #5 on: 27/02/24 23:09 »
You're welcome! I'm glad to hear that it went smoothly.
Logged

  • Print
Pages: [1]   Go Up
« previous next »
  • PhreeqcUsers Discussion Forum »
  • Beginners »
  • Installation questions »
  • PHREEQC COM: 'A dynamic link library (DLL) initialization routine failed.'
 

  • SMF 2.0.19 | SMF © 2021, Simple Machines | Terms and Policies
  • XHTML
  • RSS
  • WAP2