c# - Song.fromURI() 抛出异常?

标签 c# c#-4.0 xna xna-4.0

我一直在尝试在我当前的应用程序中包含 Song.FromURI() 方法,但总是出现“CrossThreadMessagingException”。

我已经开始了一个新项目,并从字面上复制并粘贴了 MSDN 示例 (http://msdn.microsoft.com/en-us/library/ff634558.aspx) 中的代码,但异常仍然发生。它似乎是无声的(没有终止)但阻止访问任何成员。

谢谢。

Uri uriStreaming = new Uri("http://www.archive.org/download/gd1977-05-08.shure57.stevenson.29303.flac16/gd1977-05-08d02t06_vbr.mp3");
Song song = Song.FromUri("StreamingUri", uriStreaming);


'song.Album' threw an exception of type 'Microsoft.VisualStudio.Debugger.Runtime.CrossThreadMessagingException'
'song.Artist' threw an exception of type 'Microsoft.VisualStudio.Debugger.Runtime.CrossThreadMessagingException'
'song.Genre' threw an exception of type 'Microsoft.VisualStudio.Debugger.Runtime.CrossThreadMessagingException'
'song.PlayCount' threw an exception of type 'Microsoft.VisualStudio.Debugger.Runtime.CrossThreadMessagingException'

最佳答案

XNA 团队的 Shawn Hargreaves 不久前在 MSDN 上发布了这个,我认为它与你在这里的内容有关:

Many of the media player properties cannot be evaluated when your program is paused in the debugger. It's not possible to run complex property getters that involve communicating with the media player thread, because that thread is suspended while your program is broken in the debugger, so is unable to run the code that would normally report the value of the property.

This is just a debugger artifact, and should not cause any problems if you run your program normally, or step through it in the debugger. It only affects the debugger property display, not the actual execution of your code.

关于c# - Song.fromURI() 抛出异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15392396/

相关文章:

c# - 每秒运行一次函数 Visual C#

c# - 出错时是否可以忽略异常?

c# - 如何制作一个窗口管理器?

xna - 指向多个渲染目标

c# - 将 SQL 语句的结果转换为列表

c# - 如何将包含其他第三方 C 库的 C++ project_A 链接到另一个 project_B

javascript - Web 表单页面内的 ASP.NET 4 表单

c# - 如何使用 openxml 和 C# 在 Excel 工作表中获取范围

c# - Entity Framework DbContext : Value cannot be null, 参数名称来源

c# - 将一系列瓷砖拼接在一起