win32ole errors with ruby 2.4.1

418 views
Skip to first unread message

Thierry

unread,
Jun 1, 2017, 6:56:30 AM6/1/17
to RubyInstaller
Hi everyone,

Thanks for the ruby 2.4.1 installer!
I post here a problem in hope somebody will have an idea of a direction to search for the solution:
I have installed 2.4.1 on 6 machines (4 desktops & 2 laptops). These machines also have 2.3.1. They are all configured "the same" (Win 7 ultimate, Office 2003). The following piece of code runs perfectly well on all machines under ruby 2.3.1

require 'win32ole'
access = WIN32OLE.connect('C:\\test\\test.mdb')

(test.mdb is an empty Access database)

This also runs fine under ruby 2.4.1, except for one machine, where I get:

test.rb:2:in `connect': failed to bind moniker `C:\test\test.mdb'
(WIN32OLERuntimeError)
    HRESULT error code:0x80070057
      The parameter is incorrect.
        from test.rb:2:in `<main>'

I tried excel:

require 'win32ole'
access = WIN32OLE.connect('Excel.Application')

If excel is closed (all machines, all ruby versions):

test.rb:2:in `connect': OLE server `Excel.Application' not running (WIN32OLERuntimeError)
    HRESULT error code:0x800401e3
      Operation unavailable
        from test.rb:2:in `<main>'

If excel is running (one machine only, ruby 2.4.1 only):

test.rb:2:in `connect': failed to create WIN32OLE server `Excel.Application' (WIN32OLERuntimeError)
    HRESULT error code:0x80070057
      The parameter is incorrect.
        from test.rb:2:in `<main>'

I tried to google this, found the idea to cleanup the TEMP directory (no effect)... I'm stuck: anyone has an idea?
Thanks

-- Thierry

Dušan D. Majkić

unread,
Jun 1, 2017, 7:07:49 AM6/1/17
to rubyin...@googlegroups.com
> WIN32OLE.connect('Excel.Application')

Try with starting the new Excel instance:

excel = WIN32OLE::new('Excel.Application')

For "failed to bind moniker" error - check if file exists, or that
user has access rights to file.

Thierry

unread,
Jun 1, 2017, 7:12:32 AM6/1/17
to RubyInstaller
Thanks, but that is not the problem: otherwise, it would not work under 2.3.1

Dee L

unread,
Aug 24, 2017, 1:56:15 PM8/24/17
to RubyInstaller
I'm also having a problem with WIN32OLE on Ruby 2.4.1.  I have code code for driving the IBM PCOMM mainframe terminal emulator that is working 2.3, but does not work in 2.4.  Did you ever find a solution for this?

Thierry

unread,
Aug 25, 2017, 5:20:35 AM8/25/17
to RubyInstaller
Hi,
Until today, no: it works on all machines except one, I don't know why. Do you have the problem whatever the machine, or on some machines only?
-- Thierry

Iain Beeston

unread,
Nov 23, 2017, 9:31:31 AM11/23/17
to RubyInstaller
I'm also getting this issue.

I have WIN32OLE code that works on ruby 2.3.3, but on ruby 2.4.2 the same code can connect to the OLE server but gets back empty strings or zeroes for responses. I can reproduce the issue on windows 10 and windows 8.

Lars Kanis

unread,
Nov 23, 2017, 12:42:48 PM11/23/17
to Iain Beeston, RubyInstaller
Did you check setting RUBY_DLL_PATH like in this issue: https://github.com/oneclick/rubyinstaller2/issues/71
?

--
Regards, Lars

Iain Beeston

unread,
Jan 23, 2018, 12:13:13 PM1/23/18
to RubyInstaller
Sorry, now I realise I have a slightly different issue to the original. My problem is not that win32ole fails to connect, but that it connects and gets back empty responses from the OLE server. I accept that on ruby 2.4 and 2.5 I need to set RUBY_DLL_PATH (otherwise I get similar errors to Thierry, above), but it doesn't resolve my issue with empty responses.

Thierry

unread,
Jan 31, 2018, 12:53:03 PM1/31/18
to RubyInstaller
Hi Lars,

We tried this method, but it did not work.
Since the problem is on only one machine out of six, I think it's an obscure configuration difference, but I'm out of ideas for a direction into which to search... When I google "ruby win32ole failed to bind moniker", I find... my post. (-_-)

Regards,
-- Thierry

Lars Kanis

unread,
Feb 1, 2018, 3:49:16 PM2/1/18
to RubyInstaller
Hi Thierry,

the error comes probably from here. I don't know the win32ole library well enough to say what this error means.

Maybe the root cause is one of this:

1. A change in win32ole. Looking into the ruby git repository the changes within this library between ruby-2.3.1 and 2.4.1 seems to be manageable. There is at least nothing obviously that could cause you this error.

2. The library loading search paths have changed between rubyinstaller-2.3 and 2.4. You already tested to set RUBY_DLL_PATH to PATH in order to ensure that all DLLs can be found. However Windows specifies that the PATH is is processed from left to right, but this is not specified for RUBY_DLL_PATH. So you maybe should have a closer look at what the PATH contains and check what you program loads (per Sysinternals ProcessMonitor or so).

3. The compiler has changed from gcc-4.7 to 7.1 between rubyinstaller-2.3 and 2.4. You could use a gcc-7.1 compiled ruby-2.3.4 from here to cross-check whether that makes a difference.

Hope this helps!

--
Kind Regards,
Lars

Reply all
Reply to author
Forward
0 new messages