Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1644
  • Last Modified:

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

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
pgirardier
Asked:
pgirardier
  • 6
  • 5
  • 4
2 Solutions
 
mbonaciCommented:
Place INI file in
   Lotus\Notes\
and ID file in
   Lotus\Notes\Data
folder.

Or try this method:
session.InitializeUsingNotesUserName( "username", "secretPassword")
0
 
Bill-HansonCommented:
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
 
pgirardierAuthor Commented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Bill-HansonCommented:
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
 
Bill-HansonCommented:
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
 
pgirardierAuthor Commented:
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
 
mbonaciCommented:
Have you tried to run it while Notes client is opened?
Where are the ID files stored?
0
 
mbonaciCommented:
Have you copy-pasted that command line param or you typed it, cuz' there's space following word Domino?
0
 
Bill-HansonCommented:
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
 
pgirardierAuthor Commented:
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
 
mbonaciCommented:
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
 
Bill-HansonCommented:
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
 
pgirardierAuthor Commented:
Thanks a lot for your great help.
0
 
Bill-HansonCommented:
I'm just curious how this turned out.  Which workaround did you use and how effective was it?
0
 
pgirardierAuthor Commented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now