What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Plug-Ins » Installing with .NET Framework

1 votes - 5 average   Installing with .NET Framework
Author: Message:
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
O.P. Installing with .NET Framework
There are a lot of problems with people trying to install .NET plugins... I've had them too, but I think I've finally found the right solution, so I'll post it here.

I assume you have got a plugin written in C# or VB.NET, and I'll destribe a plugin with the MessengerAPI and without. I do have Visual Studio.NET, so I'll refer to that sometimes. It is possible to do all this from the command line, but I'll not describe how.

Guid
First of all, your plugin needs a Guid. You can create a unique guid by choosing Tools -> Create Guid in VS.NET. To add the Guid to your plugin do this:
code:
VB.NET:
<Guid("936DA01F-9ABD-4d9d-80C7-02AF85C822A8")> _
Public Class MyPlugin

C#:
[Guid("936DA01F-9ABD-4d9d-80C7-02AF85C822A8")]
public class MyPlugin


Strong name
Your plugin also needs a strong name. You can generate a strong name with the tool named "sn". You have to generate a keyfile with the command:
code:
sn -k keyfile.snk
Place that in your plugin dir and then do in AssemblyInfo.cs or AssemblyInfo.vb:
code:
VB.NET:
<Assembly: AssemblyKeyFile("..\\..\\keyfile.snk")>

C#:
[assembly: AssemblyKeyFile("..\\..\\keyfile.snk")]


If you use the MessengerAPI, that needs a strong name too. Goto Project Properties > Common Properties > General > Wrapper Assembly Key File
and add our strong name key file: keyfile.snk
(thanks to n0n4m3)

Extra options
Although a lot of people say you will need the option "Register for COM Interop", it's isn't necessary. So you can leave the rest of the options default.

Interop.MessengerAPI:
If you use the Interop.MessengerAPI.dll, you should add it to the references by right clicking References and then choose Add Reference. Search the "COM" list for "Messenger API Type Library" and add this. Now you can use the MessengerAPI.

Build
Now you can compile your plugin. Your brand new plugin is outputted to the output dir. If you use the messengerAPI, there is also a dll named Interop.MessengerAPI.dll.

Installing
To install your plugin, you will have to take the following steps:
[list=1]
[*]Make a new directory for your plugin (I.E. C:/Program Files/MyPlugin). Let the user choose this in your setup!
[*]Copy the plugin to that dir, and if you use the MessengerAPI, also copy Interop.MessengerAPI.dll to that directory
[*]Register your plugin using regasm. The syntax is: regasm /codebase "C:/Program Files/MyPlugin/MyPlugin.dll"
[*]Add a registry value to HKEY_LOCAL_MACHINE\SOFTWARE\Patchou\MsgPlus2\RegisteredPlugins. You can choose the name yourselves (MyPlugin.dll for example) and the value should be the complete class name (namespaces.classname). For example: MyCompany.MyPlugin
[*]Let messenger reload the plugins by broadcasting the "MessengerPlus_PluginChange" value, OR exit msn at the start of the install and restart it afterwards
[/list]

Regasm can be found in the following directory:
{win}\Microsoft.Net\Framework\{FrameWorkName}\RegAsm.exe

The windows directory constant will be available in the most common installers (usualy it's C:/WINDOWS off course, but dont assume it is!) and the FrameWorkName you can get from the registry.

My Inno Setup script I wrote for it is:
code:
function FrameWorkName(Param: String): String;
var
  Names: TArrayOfString;
  I: Integer;
  FrameworkInstall: Cardinal;
begin
  Result := '';
  if RegGetSubkeyNames(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP', Names) then begin
    for I := 0 to GetArrayLength(Names) - 1 do begin
       RegQueryDwordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\'+Names[I], 'Install', FrameworkInstall);
       if FrameworkInstall = 1 then begin
          Result := Names[I];
       end;
     end;
  end;
end;


I'll explain it. It loops trough the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP key backwards. If there is a key that contains the value Install and that Install value is true, you can assume that that framework version is installed or has been installed once.
This function returns the latest framework version found and if it wasn't found, it returns an empty string.

Finally...it works!
I hope this tutorial helps you getting started with installing your plugin. When you have windows XP and no other plugins running, this should work (if there are no errors in your code off course).
I haven't been able to get multiple .NET plugins running at the same time, so if you are testing, please uncheck all the other plugins because that may be the problem. I've contacted Patchou about this a couple of days ago but he didn't answer. But we all know he's a busy man.
To let plugins with the messengerapi working, you should have windows messenger installed. In windows XP this is pre-installed, on windows 98 it isn't. So keep that in mind, it may explain weird behavior of your plugin!

This post was edited on 11-06-2005 at 02:36 PM by J-Thread.
09-16-2005 06:23 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Installing with .NET Framework - by J-Thread on 09-16-2005 at 06:23 PM
RE: Installing with .NET Framework - by J-Thread on 10-08-2005 at 08:11 AM
RE: Installing with .NET Framework - by fas on 03-08-2006 at 11:51 AM
RE: Installing with .NET Framework - by J-Thread on 03-08-2006 at 12:14 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On