Solved

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

Posted on 2009-05-11
15
1,427 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now