INTERACT FORUM

Please login or register.

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

Author Topic: Busy Box VB6 to Busy Box VB.NET in a few Easy Steps!  (Read 4132 times)

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Busy Box VB6 to Busy Box VB.NET in a few Easy Steps!
« on: January 02, 2006, 10:45:50 am »

Introduction
These instructions are how I created a VB.NET Busy Box from the sample one provided by JRiver for VB 6.0

First of all I'll go through what needs to be done, then the steps
that need to be performed.

Estimated Cooking time 30 minutes.
Estimated Preparation time 30 minutes

Difficulty
Fairly Easy.  Just follow the steps, you don't
need to understand everything I've written...

Requirements
Visual studio 2003 or later (Tutorial designed with 2003)

Preparations.
I'll leave it for you to find each of these command utilitys. 
I think you should find them under your Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin
  • sn.exe
  • tlbimp.exe
  • Regasm.exe


For ease of use you might consider setting the path enviroment variable to this location
in your command prompt using something like
SET PATH=C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin;%PATH%



Regasm The BusyBox.NET plugin once completed will registered using the Regasm /Codebase tool.
This creates a place in the registry so that programs such as Media Center can find it.
It is similar to the regsvr32.exe tool that was used with ActiveX components or MFC dll's.
Any assemblie to be registered using Regasm /Codebase must be Strong Named(Also known as signing).  I'm unsure to the purpose of Strong Naming, so if anyone wants to chip in something there feel free.   

TlbImp If an assembly is strong named then all of it's sub-assemblys must also be strong named.  This includes the Media Center Interface file called MediaCenter.tlb
Luckilly for us theres a utility called TlbImp.exe which will sign the Media Center Interface file and produce a new DLL assembly wrapped file.

sn First of all however we need a key file to sign everything with.
For this we need one further utility called sn.exe which magically creates key files out
of no where!

Creating the Key File
1. Open a Command Prompt
2. Find the directory which contains sn.exe
3. type sn -k outputfile.snk
where outputfile is a name of your choice

This will create a new key file.  Put it somewhere useful

Upgrading the MediaCenter tlb file
You'll find the old tlb file in your Media Center directory under
Program Files\J River\Media Center 11\Media Center.tlb
Alternativley it's shipped as part of the interface sdk available here
http://www.jrmediacenter.com/DevZone/interface_sdk.zip
1. Make a copy of this file to the directory where your new keyfile is
2. In the command prompt you need to be able to use the tlbImp.exe utility
to do the following
3.  tlbimp.exe "Media Center.tlb" /keyfile:newKey.snk /out:MediaJukeBox.dll
Note it's called MediaJukeBox.dll to match the code of the old busy box...
In new code it would be advisable to change it to MediaCenter.dll

tlbimp should generate no error messages

Recipe
1.  Take one highly nutritous VB 6 BusyBox.
I find the one available here works well (Also a part of the sdk)
http://www.jrmediacenter.com/DevZone/interface_sdk.zip
2. Open Visual Studio.NET
3. Open the File menu, and select Convert from the Open Menu
4. Use the VB Upgrade Wizzzzzard to upgrade the project to VB.NET
5. In the Soloution Explorer select the BusyBox Project
6. Open up the references Node underneath the busybox project.
7. Delete the reference to MediaJukeBox
8. Add a reference to your newly created Media Center Signed Interface DLL "MediaJukeBox.DLL"
It should appear as MediaJukeBox, to replace the one you removed...
9. Open AssemblyInfo.vb from the soloution explorer
10. Add the following line
<Assembly: AssemblyKeyFile("F:\NewKey.snk")>
underneath the other Assembly lines
Where F:\NewKey.snk points to your new keyfile
11. Rebuild the Solution

With a bit of luck this should compile, with no errors and no warnings!

Installation
Take a look in your bin directory and you'll find a few files
Of these you will need MediaJukeBox.DLL which is identical
to the one you made earlier, and the BusyBox.DLL file.
Place these in a nice new accessable directory, this
can be a subdirectory of plugins, but I recommend not the actual plugin directory for MC*
Either in a Command Prompt or using a batch file
Run these commands
%windir%\Microsoft.NET\Framework\v1.1.4322\Regasm /Codebase BusyBox.dll
%windir%\Microsoft.NET\Framework\v1.1.4322\Regasm /Codebase MediaJukebox.dll

There should be no error messages on either of these.

Finally.  Take the .REG file from the original VB6 Busy Box.
Open it up in Notepad
Change the line
"ProdID"="BusyBoxCtrl.BusyBoxCtrl"
to match the prog ID set in BusyBoxCtrl.vb which should be something like this
"ProdID"="BusyBoxCtrl_NET.BusyBoxCtrl"

Also Update the Version Number with the version number from
the new BusyBox.dll file
Find this by right clicking on the DLL file, properties, version tab,
Assembly version.


Change the line
[HKEY_LOCAL_MACHINE\Software\JRiver\Media Jukebox\Plugins\Interface\Busy Box]
to
[HKEY_LOCAL_MACHINE\Software\JRiver\Media Jukebox\Plugins\Interface\Busy Box.NET]
(This is just the name that MC displays as the plugin name).

Save the reg file.
Now I find that closing MC at this point helps although it
shouldn't really be necassery.
Run the reg file.

Step 45. (Optional)
Pray to which ever god you feel is most likely to help you
in this moment of need.

Final Step
Open MC. 
With a bit of luck your Plug in should be up and Running!

Alex B

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 10121
  • The Cosmic Bird

Nice post!    :)

BTW, what does it do?

Is this the long-awaited coffee maker plug-in? Can it make cappuccino too?
Logged
The Cosmic Bird - a triple merger of galaxies: http://eso.org/public/news/eso0755

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D

Haha, No I'm working on that seperatly.
I'm having problem with the milk frothing interface however
so expect it will take a while yet!

Mr ChriZ

  • Citizen of the Universe
  • *****
  • Posts: 4375
  • :-D
Re: Busy Box VB6 to Busy Box VB.NET in a few Easy Steps!
« Reply #3 on: January 31, 2006, 01:59:12 pm »

*Regasm /Codebase means that the dll file is
registered in a set directory.
If multiple assemblies are being used in one plugin multiple dll's will
be placed in the plugin directory which would be dangerous.
For this reason if going down the /Codebase route I would recommend
 that a directory is created just for the plugin.
This way if the plugin is installed to
Media Center 11\Plugins

all the dll files would be under
Media Center 11\Plugins\MyPluginDirectory
Pages: [1]   Go Up