player = instancePlayer as WMPLib.IWMPPlayer; //Here
Object instanceFolder = null;
Guid guid_IWMFolder = typeof(WMPLib.IWMPFolderMonitorServices).GUID;
IntPtr ptr1, ptr2;
try
{
ptr1 = Marshal.GetComInterfaceForObject(instancePlayer, type);
Marshal.QueryInterface(ptr1, ref guid_IWMFolder, out ptr2);
Marshal.PtrToStructure(ptr2, instanceFolder);
}
catch(Exception e)
{
It seems like the object "player" is not initialized right and stays null.
Which basically means it is not initialized on this line:
CoCreateInstance(guid_IWMPPlayer, null, CLSCTX.CLSCTX_INPROC_SERVER, guid_IUnknown, out instancePlayer);
Check if "instancePlayer" is not null after executing this line.