I need to create a COM object on server.
In VB you can do this: (tutorial)
xlApp = CreateObject("Excel.Application", "\\MyServer")
But how to do same thing on C#?
I know how to do it locally:
var infsrv = new InfoServ.TInfoServerClass();
But don’t know how to do it on server..
There’s nothing wrong with adding a reference to Microsoft.VisualBasic so that you can simply use the same method. This is very much a nicety of .NET, it would be a waste not to use it. It is however simple to do, just two lines of code:
Well, one line if you push it. In this specific case you definitely should consider adding a reference to Microsoft.Office.Interop.Excel. You can then simply use the new operator, get speedier code because you are not late-binding and get IntelliSense. If you want to stick with late binding then be sure to use the C# version 4 support for the dynamic keyword. Writing late bound code in earlier C# versions is quite painful.