1
votes

I have IBM Notes 9 and Visual Studio 2010. I'm trying to create a NOTESSESSION instance both of the following ways

http://www.ibm.com/developerworks/lotus/library/domino-msnet/index.html http://www.codeproject.com/Articles/18517/Lotus-Notes-Integration-with-Microsoft-NET-Platfor

but get the error 'New' cannot be used on an interface. After trying every permutation I can think of, still no luck. What do I need to do differently to create lotus objects?

Dim notesSession As New lotus.NOTESSESSION

Reference Lotus Notes Automation Classes Interop.lotus.dll

2
Since this is interop the first thing that comes to mind was how Microsoft did their interop with Office. They'd have interface with one name and a class with the exact same name appended with the word Class. I've never worked with Domino before but is there a NotesSessionClass by any chance?Chris Haas
I did look for this as well. As far as I can tell there are only interfaces in the imported lotus namespace. The namespace doesn't even show up contextually after typing new.Greg

2 Answers

3
votes

In the IBM.com article that you referenced, in Figure 1, notice that it lists "Lotus Notes Automation Classes" and "Lotus Domino Objects". It looks like you selected "Lotus Notes Automation Classes", but those are OLE classes and the reference was apparently generated as an interface. You want the second, the "Lotus Domino Objects", which are COM classes. Those can be instantiated in the way reflected in the documentation.

If you don't see "Lotus Domino Objects" in the references dialog, you may have a registration issue, which can be solved with the command regsvr32 nlsxbe.dll (issued from the Notes program folder).

You may need to be aware, however, of the fact that the Notes COM classes are not supported on Win64 (see the bottom of this IBM technote for confirmatiion of that.) If you didn't find them registered, that could be why. They do mostly work, but there are a few known issues - e.g., with NotesDatabase methods that return collections of design elements. If you need to be sure that you are only working with vendor-supported APIs, though, you're going to have to look at the other available approaches to working the Notes data.

1
votes

We have a reference to Interop.Domino.dll and use the follow class to instantiate:

Public NotInheritable Class LotusNotesSession
    Implements IEMailSession

    Private m_session As NotesSession

    Public Sub New(ByVal password As String)
        m_session = New NotesSession
        m_session.Initialize(password)
    End Sub
End Class