?
Solved

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

Posted on 2009-05-11
15
Medium Priority
?
1,733 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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
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 2000 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 2000 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

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
Watch the video of Kernel Migrator for SharePoint, which demonstrate the process easily of migration from SharePoint to SharePoint, OneDrive for Business & Google Drive servers, Public Folder to SharePoint, File Server to SharePoint. The tool has va…
From store locators to asset tracking and route optimization, learn how leading companies are using Google Maps APIs throughout the customer journey to increase checkout conversions, boost user engagement, and optimize order fulfillment. Powered …

568 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