简体   繁体   中英

LinqToTwitter in VB.net errors BC30652 and BC36593

I'm trying to use the LinqToTwitter package, in vb .net, to capture tweets, using the streaming option to capture them in real time.

I am getting two errors, which I have tried to correct in several ways, making several imports, but I did not succeed.

The errors are:

Lines, 12, 14, 21 and 23 - Reference required to assembly 'System.Runtime, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a' containing the type '[Object]'. Add one to your project.

Line 23 - Expression of type 'TwitterQueryable (Of Streaming)' is not queryable. Make sure you are not missing an assembly reference and / or namespace import for the LINQ provider.

Thank you!

Imports System
Imports System.Data
Imports System.IO
Imports System.Linq
Imports System.Xml.Linq
Imports System.Data.Linq
Imports LinqToTwitter
Public Class compTwitter
 Public Async Sub Stream_Twitter()
        Dim arquivo As StreamWriter
        arquivo = My.Computer.FileSystem.OpenTextFileWriter("C:\TesteTwitterDanilo\test25.txt", True)
        Dim twAuth = New SingleUserAuthorizer() With {.CredentialStore = New SingleUserInMemoryCredentialStore()}

        With twAuth.CredentialStore
            .ConsumerKey = glbTwitterConsumerKey
            .ConsumerSecret = glbTwitterConsumerSecret
            .OAuthToken = glbTwitterAccessToken
            .OAuthTokenSecret = glbTwitterAccessTokenSecret
        End With

        Dim twitterCtx As TwitterContext = New TwitterContext(twAuth)

        Dim Response As List(Of Streaming) = Await (From stm In twitterCtx.Streaming()
                                                    Where stm.Language = "pt" AndAlso stm.Type = StreamingType.Filter AndAlso stm.Track = "Twitter"
                                                    Select stm).StartAsync(Function(stm) Escreve_no_Arquivo(arquivo, stm))
        arquivo.Close()
    End Sub
End Class

The reason, based on your comment, is that you're trying to run it in a Web application. Web applications are stateless. That means when the user makes a request, the Web application instantiates the page, handles the request, and then allows the page (and other objects) instance to be garbage collected. Translated to your situation, the user requests the page, it instantiates LINQ to Twitter objects (including the stream), and returns. Those LINQ to Twitter instances become eligible for garbage collection and strange things happen.

Streaming code needs to run in an application that maintains state, like a console application. If you need it to run continuously, you can consider a Windows Service or Cloud service that stays running all the time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM