Hello,
I’m trying to access a class made in C# from a .dll using a LotusScript agent.
I searched on this forum… but only found answers to access Sub or Function.
The dll is quite simple (for now).
I have only one class called CalcModule and one method called AddInt that accept two arguments (Integer) and returns a sum (Long).
I’d like to call the AddInt method from a LotusScript agent by sending it two Integer… and then display the result on a document.
Is this possible?
The only thing I saw on the Notes help is this:
Declare Function CalcModule Lib “C:\Buisness.dll” (Byval x As Integer, Byval y As Integer) As Long
And I don’t know what to do after this to access the AddInt method.
Can someone help?
It may be obvious… but I’m pretty new to the dll thing.
Thanks!
Pascal
Subject: Access C# class store in a .dll from a LotusScript agent.
If it is a COM DLL you can use CreateObject to create a reference to it. Otherwise you will need to export the functions and treat is a STDCALL DLL.
Subject: RE: Access C# class store in a .dll from a LotusScript agent.
Thanks for your response!
It is not a COM DLL… so I can’t use CreateObject.
Could you give me more details about this:
“Otherwise you will need to export the functions and treat is a STDCALL DLL.”
I really don’t know what I should do.
Thanks!
Pascal
Subject: RE: Access C# class store in a .dll from a LotusScript agent.
Unfortunately, you can’t access managed code directly from unmanaged code. You’d need to have a COM wrapper – essentially a C++/C# bit of code that has both managed and unmanaged parts. The unmanaged code becomes the COM hook that’s exposed to the outside world, and the managed part does the actual talking to the Framework. Search MSDN for “COM wrapper” for more.
You might want to take a look at Proposion’s products as well if you’re doing any serious integration between Domino and .NET:
I’ve never explored getting at .NET stuff from Notes with the products, but N2N works well going the other direction.
Subject: Access C# class store in a .dll from a LotusScript agent.
Here is some free sample code for doing this (from the session I gave at Lotusphere 2003):
Subject: RE: Access C# class store in a .dll from a LotusScript agent.
Do you know whether regasm was available in Framwork 1.0? I could have used that so-o-o many times in my previous position…
Subject: RE: Access C# class store in a .dll from a LotusScript agent.
Yes, I believe so.
Subject: RE: Access C# class store in a .dll from a LotusScript agent.
Thanks to all of you!
It is now working fine!
Pascal
Subject: RE: Access C# class store in a .dll from a LotusScript agent.
Hi , Stephen if you can respond to this I would be eternally grateful. I have looked at your example and followed the code. I have registered the dll sucessfully using the regasm.exe . I have checked the registry and it does appear there but when I try to access it from My LotusScript code through createobject , It gives an error : Cannot create automation object . I am desperate need of help.
Subject: Access C# class store in a .dll from a LotusScript agent. SOLUTION.
Hi Guys…
My problem was that the dll wsa not in the proper notes directory. Our Notes installation is done differently where our data directory is placed elsewhere and there is another notes folder there. I had to look for the notes folder where the notes.ini was found. I deleted all other copies of the dll on my machine. Placed the dll in the proper notes folder and executed the Regasm.exe under the following folder structure. This was run from the command line prompt.
C:\windows\Microsoft.net\Framework\V1.1.4322> Regasm c:\notes\EncryptionWrapper.dll
It gave me a message that the dll was successfully registered.
I then restarted and went into notes again. Created an agent with the security setting: Allow restricted operations. In the agent I had the following code :
Dim Object1 As Variant
Dim ReturnValue As Variant
Set Object1 = CreateObject("EncryptionWrapper.EncryptionWrapper")
It ran successfully and created the object for me.