I am trying to control iTunes using ASP.NET with different levels of success, but no one matches my situation. I went through the website and tried all the solutions provided without much luck. I tried using many different iTunes COM libraries (even the one on the Apple Developer website), still no luck. The problem is that when I use the Visual Studio development server to instantiate an iTunes COM object - iTunesApp - it works fine and allows me to control iTunes. This also works great in Console and WinForms. But as soon as I switch it to using the IIS server, nothing works. I need it to work as a website under ASP.NET so that it can receive requests from other devices.This has tremendous potential for creating a web-based management application and essentially creating a web-based API in iTunes. It generates the following error when creating a new instance of the iTunesApp class:
Getting the factory COM class for a component with CLSID {DC0C2640-1415-4644-875C-6F4D769839BA} failed due to the following error: 80080005 Server execution error (exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
I used the file first iTunes.Interop.dllwhich is used in many projects on the Internet. I tried many times with no luck and then tried to register the DLL, which caused the error to not find the entry point to the DLL. So, I found that you should give permission to identify the application pool that the web application is running and run the DCOM service in Windows Component Services. I did this and also gave access to everyone, still nothing. Then I tried to use the COM library installed by iTunes (when you go to the "Add Link" link instead of viewing it in a DLL file, I went to the "COM" tab and chose 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, because Windows recognizedthat as installed (and I could not register the source file iTunes.Interop.dll - Windows will not know that it was there).
, iTunes iTunes.Interop.dll . , CLSID (DC0C2640-1415-4644-875C-6F4D769839BA) iTunes " ", " \DCOM\iTunes\", F98206B5-F052-4965-9FA0-85F61BC3C19D. , DCOM Windows. CLSID , , DCOM ( ID Computer\HKEY_CLASSES_ROOT\Wow6432Node\AppID), ). CLSID , -, . Google , , iTunes, .
. COM STA -, MTA, , , STA, COM. . , , Visual Studio Development Server ( Console WinForms) , IIS .
, ( ):
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();
}
}
}
: var iTunes = new iTunesApp();
, . . .
P.S.: , , , , , . .