gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 13:45:48 24 4
gpt4 key购买 nike

我一直在尝试在我当前的应用程序中包含 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com