简体   繁体   English

VB.net中的LinqToTwitter错误BC30652和BC36593

[英]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. 我正在尝试使用vb .net中的LinqToTwitter包来捕获推文,并使用流式传输选项实时捕获它们。

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]'. 第12、14、21和23行-程序集'System.Runtime,版本= 4.0.0.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a'(包含类型[Object])的引用。 Add one to your project. 将一个添加到您的项目。

Line 23 - Expression of type 'TwitterQueryable (Of Streaming)' is not queryable. 第23行-类型为'TwitterQueryable(Of Streaming)'的表达式不可查询。 Make sure you are not missing an assembly reference and / or namespace import for the LINQ provider. 确保您没有丢失LINQ提供程序的程序集引用和/或名称空间导入。

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应用程序中运行它。 Web applications are stateless. Web应用程序是无状态的。 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. 这意味着当用户发出请求时,Web应用程序将实例化该页面,处理该请求,然后允许对该页面(和其他对象)实例进行垃圾回收。 Translated to your situation, the user requests the page, it instantiates LINQ to Twitter objects (including the stream), and returns. 根据您的情况,用户请求页面,它实例化LINQ到Twitter对象(包括流),然后返回。 Those LINQ to Twitter instances become eligible for garbage collection and strange things happen. 这些LINQ to Twitter实例有资格进行垃圾回收,并且发生了奇怪的事情。

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. 如果您需要它连续运行,则可以考虑一直保持运行状态的Windows服务或云服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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