INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: .NET interface  (Read 3592 times)

mi5

  • Regular Member
  • Recent member
  • *
  • Posts: 16
.NET interface
« on: October 27, 2003, 06:06:01 am »

I realize that C#/VS.NET is not widely used here yet,
but I just tried a quick test and was not able to
connect to MJ's Com interface.  At first glance it
seems that all that should be necessary is:

1. Add a reference to the .TLB manually within VS
(this does succeed, and Object Browser can
subsequently show interfaces)

2. Set a pointer to the interface, which in C# would
be something like:
      MediaJukebox.IMJSchemeAutomation mjo =
         new MediaJukebox.MJSchemeAutomation();
No matter which interface I try, I get an exception
something like:

COM object with CLSID {A20DC525-1396-468C-BEEE-C86F4C335B7B} is either not valid or not registered.

Seems simple, and the code is parallel to some VB code that was posted in another thread.  Perhaps I'm overlooking something way stupid.  Any ideas?
Logged

RhinoBanga

  • Citizen of the Universe
  • *****
  • Posts: 1703
  • Developer
Re:.NET interface
« Reply #1 on: October 27, 2003, 07:07:17 am »

Logged

mi5

  • Regular Member
  • Recent member
  • *
  • Posts: 16
Re:.NET interface
« Reply #2 on: October 27, 2003, 03:53:44 pm »

I realize that C#/VS.NET is not widely used here yet,
but I just tried a quick test and was not able to
connect to MJ's Com interface.  At first glance it
seems that all that should be necessary is:

1. Add a reference to the .TLB manually within VS
(this does succeed, and Object Browser can
subsequently show interfaces)

2. Set a pointer to the interface, which in C# would
be something like:
      MediaJukebox.IMJSchemeAutomation mjo =
         new MediaJukebox.MJSchemeAutomation();
No matter which interface I try, I get an exception
something like:

COM object with CLSID {A20DC525-1396-468C-BEEE-C86F4C335B7B} is either not valid or not registered.

Seems simple, and the code is parallel to some VB code that was posted in another thread.


A brief followup to this:  I've tried the simple VB code that was listed in another thread, and I still get the "Not valid or not registered" error message.  Both VB.NET and C# are able to access the .TLB file and show classes and methods, but those are apparently not directly accessible for some reason.    The code compiles fine, but generates a runtime exception when it apparently can't find the appropriate registry entry (see above).

Is it because I'm trying to do this via a standalone EXE module?
Logged

mi5

  • Regular Member
  • Recent member
  • *
  • Posts: 16
Re:.NET interface
« Reply #3 on: October 27, 2003, 04:04:44 pm »

You tried reading this:

http://yabb.jriver.com/interact/index.php?board=6;action=display;threadid=15598


Someone has got it running.

Thanks for your reply, Rhinobanga.  It looked to me like they hadn't been able to get the code running.  The problem is sort of the opposite of what I was trying to do though:  They want to generate a COM-type plugin with .NET.  I want to use a .NET-generated EXE file to access MJ COM methods.

Flip side of the same coin, though.  Much of the interface ugliness is handled by tools in VS.NET, which can generate wrappers for code going in either direction.   But I have a feeling that we're running into two different kinds of problems.

I'd love to see a short function that simply accesses some MJ
COM methods from a standalone module.  If it's even possible, it should only take one page of code in .NET, and it would give newbies like me a good idea of what can be accomplished.
Logged

RhinoBanga

  • Citizen of the Universe
  • *****
  • Posts: 1703
  • Developer
Re:.NET interface
« Reply #4 on: October 28, 2003, 04:47:00 am »

I'm sorry I can't help anymore as I dumped VS.Net a week or so ago as it was causing way too many problems trying to debug stuff.
Logged

mhwlng

  • Regular Member
  • World Citizen
  • ***
  • Posts: 235
  • nothing more to say...
Re:.NET interface
« Reply #5 on: October 28, 2003, 08:59:08 am »

See :

http://yabb.jriver.com/interact/index.php?board=6;action=display;threadid=15994

just reference the

MCIOServer 1.0 Type Library
and Media Server Type Library

in your c# project

and everything works fine...

Regards,

Marcel Houweling
Logged

mi5

  • Regular Member
  • Recent member
  • *
  • Posts: 16
Re:.NET interface
« Reply #6 on: October 29, 2003, 03:36:18 pm »

I'm sorry I can't help anymore as I dumped VS.Net a week or so ago as it was causing way too many problems trying to debug stuff.

Yeah, it's a puzzle.  MS has fixed a lot of things and really screwed up a lot of other things.  The compelling reason to use it is the simplicity of the .NET model, but MS has to catch up with what developers were accustomed to in VS6.

VS.NET and VS6 should peacefully coexist, though, so you shouldn't have to physically ditch VS.NET.  I don't think they share any registry or directory names.

By the way, you were right about the other thread you mentioned; looks like someone in that thread (not the original poster) did get C# or VB.NET to run directly.  The details were vague.  Maybe it has to do with the version of MC they are running.

Logged

Mirko

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 495
  • Coffee ready?
Re:.NET interface
« Reply #7 on: November 28, 2003, 07:53:32 am »

Here's how:

0. you have a ready-to-go-project in VS.net (e.g. converted "BusyBox"-sample)
1. Make sure project is "COM interop"
2. Generate a GUID
3. Put this in the control-source just before the "public class":
Code: [Select]
<GuidAttribute("E1EA727B-5D11-42C1-91CE-16BF88AAF701"), ProgIdAttribute("RenamerCtrl_NET.RenamerCtrl")> _
Be sure to change the GUID to the (2) generated one
3a. I put the following in "assembly.vb" but I'm not sure if this is necessary:
Code: [Select]
<Assembly: ComVisible(True)>
<Assembly: CLSCompliant(True)>
<Assembly: AssemblyKeyFile("")>
4. use the "regasm.exe"-tool to generate a registry-file with COM-registration-information. e.g.:
Code: [Select]
REGEDIT4

[HKEY_CLASSES_ROOT\RenamerCtrl_NET.RenamerCtrl]
@="Renamer.RenamerCtrl"

[HKEY_CLASSES_ROOT\RenamerCtrl_NET.RenamerCtrl\CLSID]
@="{E1EA727B-5D11-42C1-91CE-16BF88AAF701}"

[HKEY_CLASSES_ROOT\CLSID\{E1EA727B-5D11-42C1-91CE-16BF88AAF701}]
@="Renamer.RenamerCtrl"

[HKEY_CLASSES_ROOT\CLSID\{E1EA727B-5D11-42C1-91CE-16BF88AAF701}\InprocServer32]
@="mscoree.dll"
"ThreadingModel"="Both"
"Class"="Renamer.RenamerCtrl"
"Assembly"="Renamer, Version=1.0.1427.25463, Culture=neutral, PublicKeyToken=null"
"RuntimeVersion"="v1.1.4322"

[HKEY_CLASSES_ROOT\CLSID\{E1EA727B-5D11-42C1-91CE-16BF88AAF701}\InprocServer32\1.0.1427.25463]
"Class"="Renamer.RenamerCtrl"
"Assembly"="Renamer, Version=1.0.1427.25463, Culture=neutral, PublicKeyToken=null"
"RuntimeVersion"="v1.1.4322"

[HKEY_CLASSES_ROOT\CLSID\{E1EA727B-5D11-42C1-91CE-16BF88AAF701}\ProgId]
@="RenamerCtrl_NET.RenamerCtrl"

[HKEY_CLASSES_ROOT\CLSID\{E1EA727B-5D11-42C1-91CE-16BF88AAF701}\Implemented Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}]
5. Create the usual registry-file for MC:
Code: [Select]
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\JRiver\Media Jukebox\Plugins\Interface\Renamer]
"IVersion"=dword:00000001
"Company"="2via Beratung"
"Version"="1.0.01"
"URL"="http://www.2via.de"
"Copyright"="Copyright (c) 2003, 2via Beratung"
"PluginMode"=dword:00000000
"CLSID"="{E1EA727B-5D11-42c1-91CE-16BF88AAF701}"
As you might see, CLSID is the (2) generated GUID
6. make sure the two reg-files are imported into the registry when the plugin is installed (I have not found a way to do it with the VS-Setup-Tool, but you might find out)
7. now it should work - works here

HTH,
Mirko
Logged

spasud

  • Regular Member
  • Member
  • *
  • Posts: 2
  • I'm a llama!
Re:.NET interface
« Reply #8 on: November 29, 2003, 09:54:52 am »


2. Set a pointer to the interface, which in C# would
be something like:
      MediaJukebox.IMJSchemeAutomation mjo =
         new MediaJukebox.MJSchemeAutomation();
No matter which interface I try, I get an exception
something like:

COM object with CLSID {A20DC525-1396-468C-BEEE-C86F4C335B7B} is either not valid or not registered.


I have only started looking at the MC interface today, so I may be wrong. But it looks like you are to create an object from a "public non createable" class. This will always throw an error no matter what langauge you use.

You should be able to create the following

IMJAutomation oMJ = new MJAutomationClass();

and then use this to get a schema:

IMJSchemeAutomation oSchema = MJ.GetViewScheme(yourSchemaPath);

Obviously this will not create a new schema, if that is what you want.
Logged
Pages: [1]   Go Up