vb.net - Call to LotusSession.GetDatabase works in VB but not in C# -


i have old vb code send mails using lotus notes works, have re-written c#, behaves differently:

vb:

    notessession = createobject("notes.notessession")     notesdb = notessession.getdatabase("", "") 

c#:

    _notessession = new notessession();     _notessession.initialize(passwordstring);     _notesdatabase = _notessession.getdatabase( "", ""); 

first of in c# need initialize notessession password, , secondly not accept empty string parameters @ runtime. exception thrown: "a database name must provided".

in both vb , c# refer same com : lotus domino objects

i need able call getdatabase without specifying server , database file.

thanks in advance.

solution (thanks guys):

     dynamic _notessession = activator.createinstance(type.gettypefromprogid("notes.notessession"));      _notesdatabase = _notessession.getdatabase("", ""); 

this way have no intellisense properties , methods can found here

when create new instance of notesession type in c# using new keyword, use com-interop dll referenced project @ build-time. not same thing calling createobject, requires no interop dll. closer equivalent in c# be:

type t = type.gettypefromprogid("notes.notessession"); _notessession = activator.createinstance(t); 

or, if need exact same thing, add reference microsoft.visualbasic.dll library , call microsoft.visualbasic.interaction.createobject method c#.

as richard pointed out in comments below, reason why seeing difference in behavior because creating 2 different types of objects. presumably, when call new notessession in c#, using notessession class lotus namespace, rather 1 in notes namespace.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -