Same error in a Windows XP SP3 and Windows Server 2003 SP2.
Gems installed: sinatra 0.9.4 rack 1.0.1
Code:
require 'rubygems'
require 'sinatra'
require 'win32ole'
get '/db' do
connection = WIN32OLE.new('ADODB.Connection')
connection.Open('Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=Libros.mdb')
recordset = WIN32OLE.new('ADODB.Recordset')
sql = 'SELECT * FROM Editoriales'
recordset.Open(sql, connection)
data = recordset.GetRows.transpose
recordset.Close
connection.close
data.inspect
end
No errors in Ruby 1.8.6-p383
Sorry my english
Hello.
> With Ruby 1.9.1-p243 I get this error:
Please provide the full version: ruby -v
> WIN32OLERuntimeError at /db
> failed to create WIN32OLE object from `ADODB.Connection' HRESULT error
> code:0x800401f0 CoInitialize has not been called.
>
> Same error in a Windows XP SP3 and Windows Server 2003 SP2.
> Gems installed: sinatra 0.9.4 rack 1.0.1
>
Please also isolate the Win32OLE from your web application.
Then provide the full backtrace.
> Code:
> require 'rubygems'
> require 'sinatra'
> require 'win32ole'
>
> get '/db' do
> connection = WIN32OLE.new('ADODB.Connection')
> connection.Open('Provider=Microsoft.Jet.OLEDB.4.0; Data
> Source=Libros.mdb')
> recordset = WIN32OLE.new('ADODB.Recordset')
> sql = 'SELECT * FROM Editoriales'
> recordset.Open(sql, connection)
> data = recordset.GetRows.transpose
> recordset.Close
> connection.close
> data.inspect
> end
>
> No errors in Ruby 1.8.6-p383
So that could mean Win32OLE differs, which may indicate a bug in Win32OLE.
Please create a minimal example that exposes this bug and can be
recreated by others.
Once you do that, we can determine if this is a bug and if so, report
properly to Ruby Redmine:
http://redmine.ruby-lang.org/
--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry
I have been able to reproduce this error in a small threaded script:
require 'win32ole'
Thread.new do
begin
ie = WIN32OLE.new( "InternetExplorer.Application" )
ie.visible = true
ie.navigate( "http://google.com" )
rescue Exception => e
puts e.class
puts e
puts e.backtrace
end
end
gets
The output is:
C:\test>ruby win32ole_test.rb
WIN32OLERuntimeError
failed to create WIN32OLE object from `InternetExplorer.Application'
HRESULT error code:0x800401f0
CoInitialize has not been called.
win32ole_test.rb:5:in `initialize'
win32ole_test.rb:5:in `new'
win32ole_test.rb:5:in `block in <main>'
win32ole_test.rb:13:in `gets': Interrupt
from win32ole_test.rb:13:in `gets'
from win32ole_test.rb:13:in `<main>'
If I put the "require 'WIN32OLE'" line inside the Thread block or do
not use threads the exception is not raised.
pete
Oops, I forgot to include my ruby version:
C:\test>ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
pete
Script: http://pastie.org/786354
I've run this using Pik [1], results:
C:\Users\Luis\Desktop>pik ruby -w t.rb
IronRuby 0.9.3.0 on .NET 2.0.0.0
OK
jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java
HotSpot(TM) Client VM 1.6.0_17) [x86-java]
t.rb:1:in `require': no such file to load -- win32ole (LoadError)
from t.rb:1
ruby 1.8.6 (2009-06-08 patchlevel 369) [i386-mswin32]
OK
ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]
OK
ruby 1.8.7 (2009-12-24 patchlevel 248) [i386-mingw32]
OK
ruby 1.8.7 (2009-12-24 patchlevel 248) [i386-mswin32]
OK
ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-mingw32]
WIN32OLERuntimeError
failed to create WIN32OLE object from `InternetExplorer.Application'
HRESULT error code:0x800401f0
CoInitialize has not been called.
t.rb:5:in `initialize'
t.rb:5:in `new'
t.rb:5:in `block in <main>'
ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-mswin32]
WIN32OLERuntimeError
failed to create WIN32OLE object from `InternetExplorer.Application'
HRESULT error code:0x800401f0
CoInitialize has not been called.
t.rb:5:in `initialize'
t.rb:5:in `new'
t.rb:5:in `block in <main>'
ruby 1.9.2dev (2010-01-02 trunk 26229) [i386-mingw32]
WIN32OLERuntimeError
failed to create WIN32OLE object from `InternetExplorer.Application'
HRESULT error code:0x800401f0
CoInitialize has not been called.
t.rb:5:in `initialize'
t.rb:5:in `new'
t.rb:5:in `block in <main>'
=====
Got 5 OK's and 5 IE windows.
Windows 7, x64 bits.
None of 1.9.x series worked.
Reporting this right now to Ruby Redmine with all these results, as
this is a bug of Ruby.
Done:
http://redmine.ruby-lang.org/issues/show/2618