I'm referencing domobj.tlb from my Visual Studio project to access LotusNotes objects. I am getting an "Object reference not set to an instance of an object" when I try to do notesAgent.RunOnServer(documentId). Please refer to the code below:
01 NotesSession ns = new NotesSessionClass();
03 NotesDbDirectory dbDir = ns.GetDbDirectory(ServerName);
04 NotesDatabase notesDatabase = dbDir.OpenDatabase(DatabaseName, false);
05 NotesDocument ndoc = notesDatabase.CreateDocument();
06 ndoc.ReplaceItemValue("Form", FormName);
07 ndoc.ReplaceItemValue("EmailAddress", "email@example.com");
08 ndoc.Save(true, false, false);
09 NotesAgent agent = notesDatabase.GetAgent(AgentName);
The program doesn't have any problem in saving the parameter document in step 8. So connection, username / password and other things are not the issue. When it hits step 10, it's throwing the standard .NET NullReferenceException "Object reference not set to an instance of an object". BTW, I am using C# but I don't believe the result from VB.NET would be any different.
I am kind of stuck here. Your expert opinion will be highly appreciated. I'm giving this question 500 points as I've not made any advance in past couple of days and the deadline is very near.