在IIS下运行ASP.NET控制iTunes [英] Controlling iTunes with ASP.NET running under IIS

查看:222
本文介绍了在IIS下运行ASP.NET控制iTunes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图用ASP.NET控制iTunes与不同水平的成功,但没有一个适合我的情况。我已经看过网络,尝试了所有提供的解决方案,没有太多的运气。我试过使用许多不同的iTunes COM库(即使是在苹果的开发者网站上的),仍然没有运气。问题是,当我使用Visual Studio的开发服务器创建一个iTunes COM对象的实例 - iTunesApp - 它完美地工作,并允许我控制iTunes。这也在控制台和WinForms应用程序完美地工作。但是一旦我切换到使用IIS服务器,似乎没有什么工作。我需要它作为一个网站在ASP.NET下运行,所以它可以接收来自其他设备的请求。这有巨大的潜力,建立一个web应用程序来控制和基本上构建一个基于Web的API在iTunes的周围。它在创建iTunesApp类的新实例时引发以下错误:

I've been trying to control iTunes with ASP.NET with varying levels of success, but none that fits my situation exactly. I've looked around the web and tried all of the provided solutions without much luck. I've tried using many different iTunes COM libraries (even the one that's on Apple's developer website), still no luck. The issue is, when I'm using Visual Studio's development server to create an instance of the iTunes COM object - iTunesApp - it works perfectly and allows me to control iTunes. This also works perfectly in a Console and WinForms app. But as soon as I switch it to use the IIS server, nothing seems to work. I need it to run as a website under ASP.NET so it can receive requests from other devices. This has tremendous potential for building a web app to control and essentially build a Web-based API around iTunes. It throws the following error on creation of a new instance of the iTunesApp class:


使用CLSID检索组件的COM类工厂
{DC0C2640-1415-4644-875C-6F4D769839BA}由于以下错误而失败:
80080005服务器执行失败(来自HRESULT的异常:
0x80080005(CO_E_SERVER_EXEC_FAILURE))。

Retrieving the COM class factory for component with CLSID {DC0C2640-1415-4644-875C-6F4D769839BA} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).

首先,我使用的是 iTunes.Interop.dll 文件,用于网络上的许多项目。我尝试了很多次没有运气,然后尝试注册DLL,抛出一个错误,没有找到一个入口点进入DLL。因此,我发现您必须授予该应用程序池标识的权限,该Web应用程序正在运行的应用程序池标识才能访问并在Windows组件服务中执行DCOM服务。我做到了,也给了访问大家,仍然没有。然后我试图使用iTunes安装的COM库(当你去添加引用,而不是浏览到DLL文件,我在COM选项卡下选择iTunes类型库),没有运气。我怀疑当我授予Windows DCOM组件的许可,我授予安装的iTunes COM库的许可,因为Windows认识到安装(我无法注册原始iTunes.Interop.dll - Windows不会知道它是

First I was using the iTunes.Interop.dll file that is used in many of the projects around the web. I tried many times without luck and then tried registering the DLL, that threw an error about not finding an entry point into the DLL. So then I found that you have to give permission to the Application Pool Identity that the web app is running under to acces and execute the DCOM service in Windows Component Services. I did that, and also gave access to Everyone, still nothing. Then I tried using the COM library that is installed by iTunes (when you go to Add Reference, instead of browsing to the DLL file, I went under COM tab and selected iTunes Type Library), no luck. I suspect that when I gave permission to the Windows DCOM component, I gave permission to the installed iTunes COM library since Windows recognized that as installed (and I couldn't register the original iTunes.Interop.dll - Windows wouldn't know it was there).

安装的iTunes类型库和 iTunes.Interop.dll 文件,给了我同样的前述错误。奇怪的是,错误(DC0C2640-1415-4644-875C-6F4D769839BA)中的CLSID与iTunes的应用程序ID不匹配,因为它在组件服务DCOM \iTunes\Properties窗口,其为 F98206B5-F052-4965-9FA0-85F61BC3C19D 。我的怀疑是,我没有授予Windows中正确的DCOM组件的权限。我在错误中搜索我的注册表中的CLSID,并且没有返回任何结果,所以我认为它不是任何DCOM组件的应用程序ID(所有应用程序ID都在 Computer\HKEY_CLASSES_ROOT\ Wow6432Node\AppID - 也没有找到它)。但是由于它是错误中的CLSID,它必须被引用到某个地方,我只是在任何地方找不到它。在Google上搜索任一ID都无济于事,因为它们都会返回包含iTunes的搜索结果,但没有足够的问题解答。

Both, the installed iTunes Type Library and the iTunes.Interop.dll file, gave me the same aforementioned error. Strangely, the CLSID in the error (DC0C2640-1415-4644-875C-6F4D769839BA) doesn't match iTunes's "Application ID", as it is called in Component Services\DCOM\iTunes\Properties window, which is F98206B5-F052-4965-9FA0-85F61BC3C19D. My suspicion is that I'm not giving permission to the correct DCOM component in Windows. I searched my registry for the CLSID in the error and it returns no results, so I concluded that it's not the Application ID of any of the DCOM components (all the Application ID's are under Computer\HKEY_CLASSES_ROOT\Wow6432Node\AppID - didn't find it in there either). But since it's the CLSID in the error, it must be referenced to somewhere, I just couldn't find it anywhere. Searching for either ID on Google isn't helpful either because they both return search results that include iTunes, but none specific enough to the problem.

我甚至尝试了多线程方法。由于COM库在STA模型中运行,并且Web服务器在MTA中运行,我发现的一个解决方案建议将服务器的线程执行模型转换为STA,然后调用COM库。这也没有工作。我在两个运行完全独立的计算机上复制了这个问题,在这两个计算机上,Visual Studio开发服务器(和控制台和WinForms应用程序)可以运行它,但IIS不能。

I even tried the multithreaded approach. Since COM libraries run in STA model and web servers run in MTA, one of the solutions I found suggested to convert the server's thread execution model to STA and then call the COM library. This didn't work either. I have duplicated this problem on 2 computers running completely independent, and on both computers, the Visual Studio Development Server (and Console and WinForms applications) can run it, but IIS cannot.

这里是我使用的代码(没有多线程):

Here's the code I'm using (without the multithreading):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iTunesLib;


namespace NewASPXNetduino2
{
        public partial class _Default : System.Web.UI.Page
        {
                protected void Page_Load(object sender, EventArgs e)
                {
                        Response.Write(WindowsIdentity.GetCurrent().Name + "\n");

                        var iTunes = new iTunesApp();

                        iTunes.Play();
                }
        }
}

line: var iTunes = new iTunesApp();

如果多线程代码有帮助, 。我在这一点上几乎没有方向,将喜欢任何能力的任何帮助。非常感谢。

If the multithreaded code would help, I can post that too. I'm pretty much directionless at this point and would appreciate any help in any capacity. Thanks.

PS:我已经看过互联网,并在多台计算机上多次尝试过上面提到的所有解决方案,所以请记住,回复。谢谢。

P.S.: I've already looked around the internet and tried all the solutions I've mentioned above multiple times on multiple computers, so please keep that in mind when replying. Thanks.

推荐答案

我没有itunes库的经验,但你描述的症状听起来像一个安全问题。 IIS可能作为本地帐户NETWORK_SERVICE运行,而您提到的所有其他内容(可能)作为常规用户帐户(您的)运行。

I have no experience with the itunes libraries, but the symptoms you describe sound like a security issue to me. IIS is likely running as the local account NETWORK_SERVICE while everything else you mentioned is (probably) running as a regular user account (yours).

要快速检查这一点,您可以在IIS管理器中更改应用程序池使用的帐户(位于身份选项卡下)。如果这个工作,你需要找出什么是做安全检查,看看你是否可以授权NETWORK_SERVICE作为一个有效的帐户,或者只是运行应用程序池使用不同的帐户。

To quickly check this, from in IIS manager you can change the account the application pool uses (it's under the identity tab). If this works, then you either need to figure out what is doing the security check and see if you can authorize NETWORK_SERVICE as a valid account, or simply run the application pool using a different account.

这篇关于在IIS下运行ASP.NET控制iTunes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆