尝试使用 TweetSharp 读取公共时间线时出现 SecurityException

发布于 2024-10-11 22:54:00 字数 2234 浏览 3 评论 0原文

当我收到此异常时,我正在尝试使用 silverlight 项目中的 TweetSharp 库从公共时间线中读取内容。

Unhandled Error in Silverlight Application 
Code: 4004    
Category: ManagedRuntimeError       
Message: System.Security.SecurityException ---> System.Security.SecurityException: Security error.
   at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
   at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
   --- End of inner exception stack trace ---
   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
   at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at Hammock.Web.WebQuery.GetAsyncResponseCallback(IAsyncResult asyncResult)
   at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassd.<InvokeGetResponseCallback>b__b(Object state2)
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

Twitter 对 clientaccesspolicy.xml 文件抛出 404,但 crossdomain.xml 文件获取得很好。

发出请求的代码如下:

var tweets =
                FluentTwitter.CreateRequest(new TweetSharp.TwitterClientInfo()).Statuses().OnPublicTimeline().AsJson().
                    CallbackTo((sndr, args, state) =>
                                   {
                                       var statuses = args.AsStatuses();
                                       foreach (TwitterStatus status in statuses)
                                       {
                                           _statuses.Add(status);
                                       }
                                   });
            tweets.BeginRequest();

这是一个错误还是我做错了什么?

I'm trying to read from the public timeline with the TweetSharp library from a silverlight project when I get this exception.

Unhandled Error in Silverlight Application 
Code: 4004    
Category: ManagedRuntimeError       
Message: System.Security.SecurityException ---> System.Security.SecurityException: Security error.
   at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
   at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
   --- End of inner exception stack trace ---
   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
   at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at Hammock.Web.WebQuery.GetAsyncResponseCallback(IAsyncResult asyncResult)
   at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassd.<InvokeGetResponseCallback>b__b(Object state2)
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

Twitter throws a 404 for the clientaccesspolicy.xml file but the crossdomain.xml file is fetched just fine.

The code making the request is as follows:

var tweets =
                FluentTwitter.CreateRequest(new TweetSharp.TwitterClientInfo()).Statuses().OnPublicTimeline().AsJson().
                    CallbackTo((sndr, args, state) =>
                                   {
                                       var statuses = args.AsStatuses();
                                       foreach (TwitterStatus status in statuses)
                                       {
                                           _statuses.Add(status);
                                       }
                                   });
            tweets.BeginRequest();

Is this a bug or am I doing something wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文