从 IIS 上的 ASP.NET 调用 WMPLib.mediaCollection 方法返回空列表

发布于 2024-07-07 06:56:01 字数 555 浏览 6 评论 0原文

我正在尝试从 ASP.NET 访问 Windows Media Player 库。

代码如下:

WMPLib.WindowsMediaPlayer mplayer = new WMPLib.WindowsMediaPlayer();

WMPLib.IWMPStringCollection list = mplayer.mediaCollection.getAttributeStringCollection("艺术家", "音频");

使用 VS2005 开发 Web 服务器运行时返回非空列表,但使用 IIS 时返回空列表。

设置模拟:

System.Security.Principal.WindowsImpersonationContext impersonationContext = ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();

没有帮助。 看来 WMPLib 仍然不认为它以拥有库的用户身份运行。

有办法解决这个问题吗?

I am trying to access a Windows Media Player library from ASP.NET.

The following code:

WMPLib.WindowsMediaPlayer mplayer = new WMPLib.WindowsMediaPlayer();

WMPLib.IWMPStringCollection list = mplayer.mediaCollection.getAttributeStringCollection("artist", "audio");

Returns an non-empty list when run using the VS2005 development web server but an empty list when using IIS.

Setting impersonation with:

System.Security.Principal.WindowsImpersonationContext impersonationContext = ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();

Doesn't help. It seems that WMPLib still doesn't thinks its running as a user who has a library.

Is there a way to get around this?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橘亓 2024-07-14 06:56:01

您是否尝试过在 ASP.NET 中通过 web.config 进行配置? 当您在 VS2005 调试器中运行时,您(可能)以您自己的身份运行代码,但在 IIS 下时,您将以 IUSR_machinename 或其他低权限系统帐户的身份运行代码。

尝试将类似的内容添加到您的 web.config 文件中:

<system.web>
<identity impersonate="true" userName="MYDOMAIN\myuser" password="p@ssw0rd" />
</system.web>

不知道这是否适用于媒体播放器,但它适用于其他与身份/安全相关的问题。

Have you tried configuration via web.config in ASP.NET? When you're running in the VS2005 debugger, you're (probably) running code as yourself, but when under IIS you'll be running it as IUSR_machinename or another low-permission system account.

Try adding something like this to your web.config file:

<system.web>
<identity impersonate="true" userName="MYDOMAIN\myuser" password="p@ssw0rd" />
</system.web>

No idea whether this works with Media Player specifically, but it works for other identity/security related problems like this.

入画浅相思 2024-07-14 06:56:01

我遇到了类似的问题:代码在我的本地计算机上运行良好,但是一旦部署到我的家庭服务器上,它就无法从媒体库中提取任何内容(我可以打开媒体播放器来验证库中是否有歌曲)

起初我以为这也是一个进程问题,所以我尝试将应用程序池设置为在我自己的帐户下运行,并通过身份模拟标签进行设置; 都没有解决问题。

我不确定还有哪些其他差异会导致该问题

I've run into a similar problem: the code works fine on my local machine, but once deployed on my home server, it can not pull anything out of the media library (I can open media player to verify there are songs in the library)

At first I thought it was a process issue as well, so I tried both setting the application pool to run under my own account, and to set it via the identity impersonate tags; neither resolved the issue.

I'm not sure of what other differences would cause the issue

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文