INTERACT FORUM
Windows => Plug-in Development => Topic started by: tommer on December 09, 2005, 01:00:52 am
-
Reference is made to this post: http://yabb.jriver.com/interact/index.php?topic=28732.0
I've implemented the following code:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MediaJukebox;
namespace WindowsApplication1
{
public partial class fStart : Form
{
public fStart()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
MJAutomation aut = null;
aut = (MJAutomation)System.Runtime.InteropServices.Marshal.GetActiveObject("MediaJukebox Application");
MJPlaylistsAutomation playlists = aut.GetPlaylists();
for (int i = 0; i < playlists.GetNumberPlaylists(); i++)
{
MJPlaylistAutomation playlist = playlists.GetPlaylist(i);
listBox1.Items.Add(playlist.Name);
}
}
}
}
However, I'm receiving the following error message:
System.Runtime.InteropServices.COMException (0x800401E3): Operation unavailable. (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))
at System.Runtime.InteropServices.Marshal.GetActiveObject(Guid& rclsid, IntPtr reserved, Object& ppunk)
at System.Runtime.InteropServices.Marshal.GetActiveObject(String progID)
at WindowsApplication2.Form1.button1_Click(Object sender, EventArgs e) in C:\...
Anybody knows what I'm doing wrong??
Or, anybody has a working c# automation program???
Regards
Tom
-
Hey,
well I'm no C# mastermind exactly, only played with VC# Express a bit, but I'd try to change a these lines:
MJAutomation aut = null;
aut = (MJAutomation)System.Runtime.InteropServices.Marshal.GetActiveObject("MediaJukebox Application");
to:
IMJAutomation aut = null;
Object = obj;
obj = aut.GetActiveObject("MediaJukebox Application");
Hope it helps...
Cheers,
Jens
-
GetActiveObject() will only succeed if Media Center is running. See this thread for how to handle both cases:
http://yabb.jriver.com/interact/index.php?topic=27357.0
-
Seems like I'm having a problem with ActiveX registration :(
Anyhow, I changed to VB.NET, seems like C# is a little bit to complicated for me...
-
:-\
Snap.
Theres loads of people in the past that seem to have got this to
work, but it doesn't seem to work now?
I'm wondering is something broken or am I doing something stupid?
Are there any other plugins that use this that I can test with?
-
I think it is broken.
Looking in the registry, when the task name was changed to Media Center.Exe from Media~1.exe it
wasn't updated for out of proc.
Additional Note...
Actually not sure this is the cause of the problem..
-
Just done some C++ Tests.
If I do CreateObject then GetActiveObject works...
otherwise it doesn't.
-
*Bump*
It would be really good to get this working, because it would mean that C#
Scripts could be set up to run from the command line.
A "yeh it's broken, we'll fix it sometime,
or a it's working fine:- learn to code would do" :)
-
Does MC11.exe use out of proc disproving my theory?
ChriZ
Additonal Note:
Nope. MC11.exe still works whether the CLSID is there or not.