FSharp.Data.Toolbox icon indicating copy to clipboard operation
FSharp.Data.Toolbox copied to clipboard

F# Data Toolbox: Twitter type provider - single-threaded apartment

Open JonnyBoats opened this issue 10 years ago • 2 comments

Referencing: http://fsprojects.github.io/FSharp.Data.Toolbox/TwitterProvider.html

When building a F# console application (as opposed to FSI) application-only authentication works just fine.

However let connector = Twitter.Authenticate(key, secret) fails with:

System.Threading.ThreadStateException was unhandled Message: An unhandled exception of type 'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll Additional information: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.

JonnyBoats avatar Apr 30 '14 02:04 JonnyBoats

It seems to be a threading issue http://stackoverflow.com/questions/1418466/single-threaded-apartment-cannot-instantiate-activex-control Would it work if you created the new thread for Twitter connector yourself in your application?

I'm not sure if the PIN-based authentication is the right thing to do from a console application. There are other access options as well that we haven't implemented so far: https://dev.twitter.com/docs/auth/obtaining-access-tokens (we'll be happy for pull requests!)

evelinag avatar Apr 30 '14 11:04 evelinag

Hi

Got the same issue here trying in a compiled f#. (Interactive is great !)

Just a newbie here, here are my two cents

I think this has to do with this

http://stackoverflow.com/questions/6271078/f-windows-form-in-a-compiled-program

and this

http://stackoverflow.com/questions/13136605/object-oriented-hello-world-using-windows-forms-in-f

So maybe the form code for member TwitterWeb should use the compiler directives to tell if it is interactive or not

Thanks

ghost avatar May 14 '14 08:05 ghost