Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling C# function from VBScript function in Web UI

Tags:

c#

vbscript

I need to call or at least pass parameters into C# function from within VBScript function (or suitable workaround) on Microsoft Azure Website Hosting i.e.:

Function VBScriptFnc(param_1, param_2, param_3)

  Dim flag;

  flag = 1

    'call the C# function or somehow pass parameters into C# function'
    csharpFunction(param_1, param_2, param_3)


  VBScriptFnc = flag

End Function
like image 505
Milan Avatar asked Jan 17 '26 15:01

Milan


1 Answers

VBScript has 5 windows into the .NET world:

  1. By doing HTTP POST/GET to a .NET handler of some kind (such as a .aspx, HTTP handler, MVC or WebAPI controller).
  2. By writing data to a file or a database for a .NET process to pick up.
  3. By exposing a .NET assembly (class library) as a COM object and adding the appropriate entries in the Windows Registry (either manually or using command utilities) so it can be called directly from VBScript. See this article.
  4. Making an executable file with .NET that is run directly from VBScript.
  5. Using PowerShell to call into a .NET assembly and using VBScript to call PowerShell.

The most straightforward option on a website is to use a GET or POST because you will steer clear of the mine fields of ACL and COM registration, but if you must go down another road I would say that PowerShell is your best bet, followed by COM interop as a third choice.

like image 108
NightOwl888 Avatar answered Jan 20 '26 05:01

NightOwl888



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!