Question : Nnotes.dll API Create Empty Replica Stubs through VB.NET 2008

Hi guys,

I hope you can help me, I'm looking for a way to create empty replica's of existing notes database on a different server in VB.NET 2008.

After searching the net I've found that the only way to do this is, is through to use of the Notes C API.

Could anyone provide the necessary code to accomplish this in a VB.NET 2008 application?

My own implementation keeps on telling me :

System.AccessVoilation Error
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Method : Int32 NSFDbCreateAndCopy(System.String, System.String, Int32, Int32, Int64, Int32 ByRef)

I think this is because I'm using the COM interface in conjunction with a DLLImport
My guess is that i will need to use the API functions to start session, open database before executing the creation of the replica, but I can't seem to get it right.

Any help would be appreciated!

Thanks

Kraeven
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
imports domino
 
Module CreateReplica
 
Const NOTE_CLASS_NONE = 0                                                      
Const DBCOPY_REPLICA = 1
Dim hDb as integer
 
 
 Public Function _
              NSFDbCreateAndCopy( _
        ByVal srcDb As String, ByVal dstDb As String, ByVal noteClass As Integer, ByVal limit As Integer, ByVal flags As Long, ByRef hDb As Integer) As Integer
    End Function
 
Public Function CreateReplicaStubs(ByVal sourceserver As String, ByVal destinationserver As String, ByVal replicaId As String,byval password as string) As Boolean
        Try
           Dim session as Domino.NotesSession
            Dim databaseke As NotesDatabase = Nothing
 
            Dim dbDir As Domino.NotesDbDirectory
            Dim SrcPath As String
            Dim DestPath As String
            Dim result As Integer
            session = New Domino.NotesSession
            session.Initialize(password)
            dbDir = session.GetDbDirectory(sourceserver)
            databaseke = dbDir.OpenDatabaseByReplicaID(replicaId)
            If databaseke.IsOpen Then
               
                SrcPath = sourceserver + "!!" + databaseke.FilePath
                DestPath = destinationserver + "!!" + databaseke.FilePath
                result = NSFDbCreateAndCopy(SrcPath, DestPath, NOTE_CLASS_NONE, 0, DBCOPY_REPLICA, hdb)
                If result = 0 Then
                        Return True
               Else
                         Return False
               End If
            else
                    Return false
            End If
        Catch ex As Exception
           Msgbox("Error occured while creating replica stub on : " + destinationserver + vbCrLf + ex.ToString)
            Return False
        End Try
 
    End Function
 
end module

Answer : Nnotes.dll API Create Empty Replica Stubs through VB.NET 2008

You'll find examples of DLLs in the C-API Toolkit, downloadable from IBM:
https://www.ibm.com/developerworks/lotus/documentation/capi/
Random Solutions  
 
programming4us programming4us