Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2009-05-11
15
1,466 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Media Player 2 31
Set value of dynamically created checkboxlist 2 41
List<PaisEntity> - show some 1 28
Please explain purpose of GZIP 4 34
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

790 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