Using NotesUI* Classes in C# with COM

The NotesUI* Classes are not accesible in Visual Studio via the References-Dialog. Also in the DesignerHelp it is said, that you can not use the UI-Classes.

 

But there is a very simple Solution in C# by using the dynamic – Keyword and the .NET System.Activator Class.

 

The following Code-Sample connects to an running Notes Client and performs some actions:

class Program
    {
        static void Main(string[] args)
        {
            dynamic session = Activator.CreateInstance(Type.GetTypeFromProgID("Notes.NotesSession"));
            dynamic uiws = Activator.CreateInstance(Type.GetTypeFromProgID("Notes.NotesUIWorkspace"));
            dynamic uidb = uiws.CurrentDatabase;
            dynamic dbDir = session.GetDbDirectory("NTSDEV2008");

            Console.WriteLine("Benutzer : {0}", session.UserName);
            Console.WriteLine("Datenbank: {0}", uidb.Database.FilePath);



            uiws.OpenDatabase("NTSDEV2008", "names.nsf");

            uiws.URLOpen("https://www.google.at");
                       
            


            Console.ReadKey(); 
        }
     }

 

I found no current usecase for this at the moment, but good to know that this is possible …

Schreibe einen Kommentar

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.