Interop type ‘iTunesAppClass’ cannot be embedded.
iTunes comes with an api you can access from any (.NET) program by adding the COM reference “iTunes 1.xx Type Library” (see iTunes COM for Windows SDK) to your Visual Studio project:
using iTunesLib; iTunesApp app = new iTunesAppClass();
When trying to instantiate an ‘iTunesAppClass’ object the compiler initially outputs the following error message, although creating an instance of this class is the only way to access iTunes:
“Interop type ‘iTunesLib.iTunesAppClass’ cannot be embedded. Use the applicable interface instead.”
This is due to a setting in the reference properties:
- Go to the Solution Explorer.
- Right click on References –> iTunesLib and hit Properties.
- Set “Embed Interop Types” to False.
This solves the described error and you can go on automating iTunes.
Remarks: For German localization settings the error message is “Der Interoptyp “iTunesLib.iTunesAppClass” kann nicht eingebettet werden. Verwenden Sie stattdessen die entsprechende Schnittstelle.”