Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
WIN32OLE
callsOleInitialize
(with STA), does this actually work?https://github.com/ruby/ruby/blob/ruby_2_1/ext/win32ole/win32ole.c#L1251
https://github.com/ruby/ruby/blob/ruby_2_1/ext/win32ole/win32ole.c#L2750
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the code that I'm currently using in the (working) Nano tests.
WIN32OLE.ole_initialize() is not called here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Odd - there are no other places that Ruby directly calls
CoInitialize
/CoInitializeEx
/OleInitialize
/OleInitializeEx
that I see. So how is Ruby able to init COM then?I wrote a trivial script in Ruby demonstrating that you are correct - this basic approach works:
Output:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my testing, I'm not seeing a failure to call
OleInitialize
from Ruby:Results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed interesting. Looks like OleInitialize calls CoInitializeEx with COINIT_MULTITHREADED (against what the documentation states), so it can be safely ignored. I'll ask the Nano team.
Output on Nano TP5:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed https://tickets.puppetlabs.com/browse/FACT-1418 to cover this as we'll have to think a little about breaking API implications.