0

I am a c# web developer but I am doing a side project that involves iTunes. I am looking at a few projects from codeplex and some of them contain Interop.iTunesLib.dll. This old article also contains the same file http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=12369.

Does anyone know where this file came from?

Thank you.

1

2 Answers 2

1

The aforementioned iTunes COM object is installed along with the app. Here is an example of Scott Hanselman using the COM object to delete duplicate tracks.

1
  • Thanks for the article. I found out the Interop.iTunesLib.dll came from the installation of iTunes and I can add it by adding a COM reference (it shows up after the installation of iTunes).
    – Wisp
    Commented Jan 17, 2013 at 3:01
0

When you install iTunes, the iTunes.exe application gets registered as COM server (likely with regsvr32.exe). It will have a small key group in the Computer\HKEY_CLASSES_ROOT registry section with the GUID of: 9E93C96F-CF0D-43F6-8BA8-B807A3370712

To reference this COM server, in your C# program, you would add the following COMReference property to your csproj file:

<ItemGroup>
    <COMReference Include="iTunesLib">
    <Guid>{9E93C96F-CF0D-43F6-8BA8-B807A3370712}</Guid>
    <VersionMajor>1</VersionMajor>
    <VersionMinor>13</VersionMinor>
    <Lcid>0</Lcid>
    <WrapperTool>tlbimp</WrapperTool>
    <Isolated>False</Isolated>
    <EmbedInteropTypes>True</EmbedInteropTypes>
    </COMReference>
</ItemGroup>

This tells the build system to use the tlbimp program to create a managed type library for the COM server that your managed module can reference. The tlbimp program will create a module called Interop.iTunesLib.dll and the build system will place a copy of this in both your bin and obj directories.

If you don't have iTunes installed, then there will be no COM server registered and your build will fail.

However, if you managed (no pun intended) to save a copy of Interop.iTunesLib.dll, then without having iTunes installed, you can reference it like so:

<ItemGroup>
    <COMFileReference Include="Interop.iTunesLib.dll">
        <EmbedInteropTypes>True</EmbedInteropTypes>
    </COMFileReference>
</ItemGroup>

In the include attribute, you can / may need to add a path component, as well. There are probably a few versions of Interop.iTunesLib.dll floating around the internet likely from different versions of iTunes.exe. Best to get this file from a trusted source.

While using the COMFileReference property will allow the project to build properly, attempting to execute the iTunes related functionality will crash the program, because that functionality is located in iTunes.exe, which in this situation, is not present.

In my project, I get around this by first checking to see iTunes.exe exists (\Program Files\iTunes\iTunes.exe), before attempting to execute any of the iTunes functionality.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.