Acessando uma classe .Net classes através do LotusScript
Diretamente do site da IBM
Problem You have created an object using Microsoft .Net and would like to create and use this object within LotusScript. How can this be done?
Solution To create a .Net DLL that is accessible from LotusScript perform the following steps:
1. Create a C# Class Library Project with the following code:
using System; public class MyTest { public string AppendStr(string s) { return s + " from inside the DLL"; } }
Note: A Visual Basic Class Library could also be created.
2. To access this DLL from anywhere on the machine you will also need to create this DLL as a shared assembly and publish the your DLL to the Global Assembly Cache (GAC). Otherwise, the DLL will be created as a private assembly and you will only be able to create the object if the DLL is in the same directory as the calling program.
To create this DLL as a shared assembly you will need to generate a cryptographically strong name for the assembly. To do this start up the Visual Studio Command Line prompt, and enter the following command:
sn -k c:\MyTest.snk
This will create an Assembly Key File name at the location c:\MyTest.snk
3. Open the AssemblyInfo.cs file of the project include the following line:
[assembly: AssemblyKeyFile(@"c:\\MyTest.snk")]
Note: For Visual Basic you will need to include this tag instead:
4. Build the project. This will build the project with the value of the Assembly Key File and allow it to be published as a Shared Assembly to the Global Assembly Cache.
5. Using the Visual Studio Command Line, change to the directory where the DLL was generated, then publish the DLL to the Global Assembly Cache using the following command:
GacUtil /i MyTest.dll
6. To make the objects in this DLL accessible via the COM interface, enter the following command:
regasm MyTest.dll
7. To access the object contained in this DLL using LotusScript use the following code:
Dim obj As Variant set obj = CreateObject("MyTest") MsgBox obj.AppendStr("This is")
The message box will display "This is from inside the DLL."
In short, once the shared assembly is published as a COM component, it can be instantiated in LotusScript using the CreateObject() function. With the exception of Step 7, all of the steps are all specific to the deployment process of Microsoft .Net components. For further information regarding any of these utilities you should refer to the Microsoft web site or Microsoft support.