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 :
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!
Const NOTE_CLASS_NONE = 0
Const DBCOPY_REPLICA = 1
Dim hDb as integer
<DllImport("nnotes.dll")> Public Function _
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
Public Function CreateReplicaStubs(ByVal sourceserver As String, ByVal destinationserver As String, ByVal replicaId As String,byval password as string) As Boolean
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
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
Catch ex As Exception
Msgbox("Error occured while creating replica stub on : " + destinationserver + vbCrLf + ex.ToString)