First of all, thank you for your answers.
I proceeded as follows:
1. I downloaded a c# interop form toolkit and wrote a simple dll called nettest.dll.
2. I registered this dll with regasm "nettest.dll" /codebase.
3. I generated an OleObject (new -> standard class) and named it n_oleobject_test
Sourcecode (PowerBuilder):
n_oleobject_test lnv_test
lnv_test = create n_oleobject_test
lnv_test.Connecttonewobject("NetTest.NetTest")
Messagebox("your default printer is?",String(lnv_test.of_getPrinter() ))
lnv_test.Disconnectobject( )
Destroy lnv_test
Sourcecode (visual studio):
public String of_getPrinter()
{
//get default printername
PrinterSettings ps = new PrinterSettings();
return ps.PrinterName ;
}
This works fine, but is this the right way at this time until PowerBuilder 2019 R2 will be released?
The "problem" is that OLEObject has late binding (runtime resolution) of each and every call. So
1) OLEObject is potentially slow. What compiler could have done is delayed and repeated at runtime.
2) No compiler checks for the API due to the late binding. So compiler pretty much just checks the number of start and end parentheses.
3) Most often, OLEObject also requires COM registration in local Windows Registry.
4) Naming standard in PowerBuilder differs from C#. I have yet to see a C# naming rule suggesting non-visual classes prefixed [n_] and functions prefixed [of_]. So someone either writes a PowerBuilder specific adapter on top of other C# classes - or your PowerBuilder app creates an adapter NVO to encapsulate the naming differences.
I prefer validation and binding appear at compile time - and I prefer having any adapter code be auto-generated into proxy classes instead of developers writing such code manually.
/Michael