.NET COM Interop to existing running MM instance

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

tss
Posts: 10
Joined: Fri Feb 04, 2005 9:25 am

.NET COM Interop to existing running MM instance

Post by tss »

I'm trying to write a simple C# application that talks to MM via COM Interop.

I create an SDBApplication instance as follows:

Code: Select all

ISDBApplication app = new SDBApplicationClass();
If MM isn't running then this works fine, but if MM is running this call causes MM to become the active application and my program blocks.

I've also tried to detect the current running object but this results in an exception:

Code: Select all

try
{
    object app = System.Runtime.InteropServices.Marshal.GetActiveObject("SongsDB.SDBApplication");
    if (app != null)
    {
        m_app = app as ISDBApplication;
        if (m_app != null)
            return m_app;
    }
}
catch (Exception ex)
{
    MessageBox.Show(this, ex.Message);
}
The exception occurs when I call Marshal.GetActiveObject, the message is: "Operation Unavailable".

Searching the internet, I've found other similar problems like this. Apparently this means the application has not registered itself in Running Object Table (ROT).

Is there another way to get back the active MM instance? Is MM not registering itself in the ROT when its started up?
jmaver
Posts: 92
Joined: Thu Feb 19, 2004 10:26 am

Post by jmaver »

What do you mean blocks?
My two line program reaches line two:

ISDBApplication app = new SDBApplicationClass();
bool isRunning = app.IsRunning;

When does it block?
Peke
Posts: 17484
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Post by Peke »

Try To read something in
http://www.cgoakley.demon.co.uk/prog/oleaut.html

It may help.
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
tss
Posts: 10
Joined: Fri Feb 04, 2005 9:25 am

Post by tss »

By "blocks" I mean my program never gets past the line:

Code: Select all

ISDBApplication app = new SDBApplicationClass();
This ONLY happens when MM is already running. When it isn't running it works fine.
jmaver
Posts: 92
Joined: Thu Feb 19, 2004 10:26 am

Post by jmaver »

This doesn't happen with mine. My apps are working regardless of whether MM is already running. Do you have any scripts that run at startup for MM that maybe get run again and could be blocking it?
Post Reply