Solved

Accessing Lotus Notes from C# - problem during lotesNotesSession.Initialize

Posted on 2009-05-11
15
1,452 Views
Last Modified: 2013-12-18
Hello,
I am trying to initiate a Lotus notes session from c# with the attached code. The notes.ini is always in the following folder:
C:\Documents and Settings\%username%\Domino
But this does not work, I always get the message: Error: impossible to open ID file.
I have referenced the path in the Environment settings though. What did I miss?
public bool InitSessionStart(string DominoServerName, string NotesPassword, string Database)
        {
            try
            {
                if (_lotesNotesSession == null)
                {
                    //Lotus Notes Object Creation
                    _lotesNotesSession = new Domino.NotesSessionClass();
 
                    //Initializing Lotus Notes Session
                    _lotesNotesSession.Initialize(NotesPassword);
                   
                    //Setting _localDatabase
 
                    string server = DominoServerName;
                    if (server == "Local")
                        server = "";
                    _localDatabase = _lotesNotesSession.GetDatabase(server, Database, false);
  
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
            MessageBox.Show("La connexion s'est effectuée avec succés", "Succés", MessageBoxButtons.OK, MessageBoxIcon.Information);
            return true;
        }

Open in new window

0
Comment
Question by:pgirardier
  • 6
  • 5
  • 4
15 Comments
 
LVL 22

Expert Comment

by:mbonaci
ID: 24354527
Place INI file in
   Lotus\Notes\
and ID file in
   Lotus\Notes\Data
folder.

Or try this method:
session.InitializeUsingNotesUserName( "username", "secretPassword")
0
 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 24354564
Don't use the classes that have the term "Class" in them.

For example, the session should be instantiated like this:

    _lotesNotesSession = new Domino.NotesSession();

Everything else looks fine.
0
 

Author Comment

by:pgirardier
ID: 24354613
I have no way to change the locations of the INI files and pf the ID files. This is done by the client and user related info are in C:\Documents and Settings\%username%\Domino.
Ans alos the Lotus Notes Help indicates: "This method can be used only on a computer with a Domino server. You can access only the local server through the Domino Objects.". This si to restrictive in my case
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 24354661
Ignore my last post.  I just tested this in one of my projects, and the class names do not seem to make a difference.  I have no idea why there are two sets of identical classes with different names, but I've never used the ones that end in 'Class'.

You do have a Notes Client or Domino Server installed on the machine that runs your C# code, right?
0
 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 24354674
The INI file should be stored in the notes program directory.  Check the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Lotus\Notes\Path for the actual location.
0
 

Author Comment

by:pgirardier
ID: 24354884
To be more precise, Lotus Notes is launched on the client'computer with the following shortcut:
C:\Lotus\Notes\notes.exe "=C:\Documents and Settings\%username%\Domino \notes.ini"

The domino server is not on the end-user' computer: only the LN client is installed
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24354955
Have you tried to run it while Notes client is opened?
Where are the ID files stored?
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24354974
Have you copy-pasted that command line param or you typed it, cuz' there's space following word Domino?
0
 
LVL 22

Assisted Solution

by:Bill-Hanson
Bill-Hanson earned 500 total points
ID: 24355107
Form the COM documentation:


"The Domino COM objects must be able to locate a valid notes.ini file, looking first in the Domino or Notes program directory and then at the PATH system variable. The KeyFileName setting in the notes.ini file specifies the user ID that COM uses."
0
 

Author Comment

by:pgirardier
ID: 24355149
The ID file is also in C:\Documents and Settings\%username%\Domino

The space after 'domino' in the URL I posted is my mistake. The launching path is fine.
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 24355477
Bill is right, COM searches for INI file using procedure he stated.
COM doesn't know which command line argument you use when you start Notes (COM needs to work even when Notes isn't started), so you'll have to relocate those ini files.

Why did you place them in the "documents & settings" subfolder in the first place?
0
 
LVL 22

Accepted Solution

by:
Bill-Hanson earned 500 total points
ID: 24355977
Mbonaci is right about me being right.   :)

He is also right about everything else in his post, and I'm wondering the same thing.

The only sure-fire fix is to use only one notes.ini, but I assume that you have your reasons.

I have three ideas for a work-around:

1) Make sure that there is not a notes.ini file in the program directory and add "C:\Documents and Settings\%username%\Domino" to the system path.  This seems to be the most straight-forward approach.

2) Have your C# code copy the correct notes.ini file into the program directory before instantiating your NotesSession.

3) COM must get it's info from somewhere, probably the registry.  If you can find the right key, you could set it to "C:\Documents and Settings\%username%\Domino" before instantiating your NotesSession (you would probably need to expand the environment string in code).  I would look at "HKEY_CURRENT_USER\Software\Lotus\Notes\Installer\VDIR_INI" first, but I really have no idea if this is right.
0
 

Author Closing Comment

by:pgirardier
ID: 31580141
Thanks a lot for your great help.
0
 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 24357828
I'm just curious how this turned out.  Which workaround did you use and how effective was it?
0
 

Author Comment

by:pgirardier
ID: 24392835
Hi Bill, sorry for the delay in responding to your questions: we had indeed to test the scenarios that your propose.
So the deletion of the notes.ini file in the initial install directory (your option 1) works perfectly and this solved my problem. Thanks a lot for your inputs.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Angular - break the dataset in chunks? 7 51
Error on link 14 48
Reset asp.net login password 4 42
Google Directions API to Map URL -C#? 3 27
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question