Using C# with MediaMonkey

Get answers about using MediaMonkey 4 for Windows.

Moderator: Gurus

LeKris
Posts: 2
Joined: Wed Jul 20, 2016 3:59 pm

Using C# with MediaMonkey

Post by LeKris »

Hi there,

I am trying to control MediaMonkey from an external program for further use
(remote controlling f.e.)

I started to write some code, but when I execute it AND MediaMonkey
is already started, I get a COMException like this:

Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80080005

followed up by a NullReference Exception.

If MediaMonkey is NOT already started, the program starts up and my program is working.

This is my C# code:

Code: Select all

 public class CMediaMonkeyManager
    {
        private SongsDB.SDBApplication m_SDBApplication;

        public CMediaMonkeyManager()
        {
            this.initialize();
        }

        private void initialize()
        {
            this.initializeMediaMonkey();
        }

        private void initializeMediaMonkey()
        {
            try
            {
                this.m_SDBApplication = new SongsDB.SDBApplication();
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
}
Hope someone has an idea.

Greetings
Peke
Posts: 17491
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: Using C# with MediaMonkey

Post by Peke »

Looks like you can't hook to existing registered COM server and that is why it works when MMW is not started.

From What I read in https://social.msdn.microsoft.com/Forum ... ?forum=clr it is not uncommon. Also http://www.codeproject.com/Questions/50 ... toryplusfo is interesting.

Somewhere you need to connect to existing instead of creating New Instance which result in fail.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
LeKris
Posts: 2
Joined: Wed Jul 20, 2016 3:59 pm

Re: Using C# with MediaMonkey

Post by LeKris »

Hi there and thanks for your help.

I think I got a solution which does not end up in an exception.

I tried another way of getting the instance. This works for both ways
either the program is already started or it not already started.
For the second scenario the program opens up an instance by itself.

This is the short but important excerpt of my code:

Code: Select all

                Type theType = Type.GetTypeFromProgID("SongsDB.SDBApplication");
                object theObject = Activator.CreateInstance(theType);
                this.m_SDBApplication = theObject as SongsDB.SDBApplication;
Hope this works for other people who could have the same problem in future.

Greetings

LeKris
Post Reply