2013-03-13 201 views
2

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

我已经开始一个新项目,并且从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' 

回答

1

肖恩从XNA团队哈格里夫斯张贴这在MSDN上了一段时间后,我认为是相对于你在这里:

许多媒体播放器的属性不能被评估时,你 程序在调试器中暂停。无法运行涉及与媒体播放器 线程通信的复杂 属性获取器,因为该线程在调试器中被暂停而您的程序被中断 ,因此无法运行代码,因此通常会运行 报告的值属性。

这只是一个调试器工件,如果您正常运行您的程序或在调试器中遍历它,应该不会引起任何问题。它 只影响调试器属性显示,而不影响代码的实际执行 。