C#, Lotus Notes 6.5.1,  Error with NotesSession.Initialize, The system cannot find the file specified.

swingtipshoes used Ask the Experts™
I'm using C# and Lotus Notes 6.5.1
In code I create a NotesSession and then I get a NotesDatabase. Sometimes when I step through the code (in Debug mode), I get a popup window when the code executes the following line of code:
The popup windows reads: Error: The system cannot find the file specified.
When this happens, I click on the OK button to close the window, and I'm still able to step through the rest of the code and everything continues to execute as expected.
However, this is a problem when this program is scheduled or automated because I have no way to tell the program to ignore any error popups and continue processing.
Is there some value that I need to set or is there another way that I should try to open a NotesDatabase? The code in question follows.

Domino.NotesDatabase _notesDatabase = null;
Domino.NotesSession _notesSession = null;

_notesSession = new Domino.NotesSession();
_notesSession.Initialize(ServerPWD);  // ERROR popup window occurs here.
_notesDatabase = _notesSession.GetDatabase(ServerName, MailFile, false);
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®


I should mention that I need this to work as a windows service.
I have found that if I put a copy of the notes.ini file in the path c:\lotus\notes, the Error popup does not appear when debugging.  However, it is still an issue after I have deployed the program as a windows service.
Is there a way that I can set the default path to something else? Points are awarded for helping me get to a working solution.
Thank you.
You need to have Notes in your Path statement and you need to have One notes ini with the correct KeyFilename indicated for your ID file.


behenderson, could you please elaborate on your answer? Where am I setting my Path statement, is this the system emvironment Path that you are referring to? Do I set that to the Notes installation path?
My notes.ini has KeyFilename set to user.id. I don't know why it's important that the notes.ini file must point to the correct Key FIle name.  However, since my windows service will allow itself to be configured to connect to any lotus notes mail file/server, it must flexible.
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

The password works with the ID file to connect.  The password by itself does not contain the information necessary to sign in to the server itself it is used in conjunction with the physical ID file.  Once the password is put into the physical ID file the encrypted keys needed for server validation are available.  So it is impertive that when you try to use notes on the system that you are not only using the correct dynamic link libraries etc.. you also need to be referencing the notes.ini file.  The Notes.ini file will be used by the dynamic link library to establish the notes session.  The most important aspect of the Notes.ini file is the pointer to the physical Encrypted ID file.  So if you have multiple Notes.ini files you can easily be pointing to one that does not reference the correct ID file.  The Notes.ini file needs to be available in the system path so that when your program looks for Notes.ini it will find it.
To put the problem more simply..

Authentication with a Notes server is NOT clear text.  You do not authenticate with the notes server directly.  Notes uses double key encryption which means that the Physical ID file needs to be available because it is used to create an encrypted channel with the server for Authentication.

RIght click My Computer, go to properties, advanced, click environment variables.  Change the SYSTEM environment variables (bottom half of screen), adding C:\Lotus\Domino or wherever you keep notes.ini into the path. That should apply to your service as well, and all should be good.


I did some more testing. Setting the PATH environment variable to the location of my notes.ini file did not fix the problem.  My notes.ini file is located in C:\Program Files\lotus\notes.
However, I did notice that if I launch Lotus Notes mail client on the machine running my windows service, the windows service runs fine from end to end.  If I close the Lotus Notes mail client and try re-running the application, it fails again.
There is something that the mail client is initializing or setting that my windows service needs to initialize a Notes Session.  Does anybody know what environment variables the mail client is setting that my windows service may need? Are we headed in the right direction or is there a totally different direction that I should be focused on?
Thank you.

Might not be an environment variable.  Could be the Notes password.  If the Notes ID is set to "share its password," then after you log in to the Notes client, the ID can be used by other processes without orompting for password.  if the NNotes client isn't open, then it still prompts for password.  (If you have Notes single sign on installed, then the Notes client won't prompt for password either, but the password sharing by the client is still nevessary -- the isngle sign on tells Notes how to unlock the ID, then Notes allows the ID to be used by other processes).


After some testing, I finally figured out my solution:
1. Create a Notes account with manager permission to the Notes mailbox.
2. Create a service account on the hosting server and configure the windows service to run as this service account.
3. Log into the hosting server as this new service account, launch Lotus Notes and switch to the Notes ID associated with the Notes account that was created in step #1, and log in with its password.
4. Exit Lotus Notes, log off server.
5. Log into service as any admin user and start the windows service.
Heh heh.

Sounds like you did a sharfed Notes installation, which means that the Notes data and some of the metadata Notes uses are aligned with individual login accounts.  So the service acocunt never had a Notes setup.

Sound right?  YTou can tell by lanuching Notes, going to preferences, and seeing where the data directory is.  Normally it would be something like C:\Lotus\Notes\Data or C:\Notes\Data or C:\Program Files\....

If instead you find it pointing somewhere is Documents and Settings, you've got a shared installation.

the real answre is not to set up the login, but to change the insatllation to non-shared, so all logins/accounts/services share one copy of Notes.


The split is fine with me.  I appreciate your effort guys.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial