Calling a c # function from a VBScript function in a web interface
I need to call or at least pass parameters in C # functions from a VBScript function (or a suitable workaround) on a Microsoft Azure website ie:
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
+3
source to share
2 answers
VBScript has 5 windows in the .NET world:
- By doing HTTP POST / GET to some .NET handler (like ASPX, HTTP handler, MVC, or WebAPI controller).
- By writing data to a file or database to get a .NET process.
- NET assembly (class library) is published as a COM object and the appropriate entries are added to the Windows registry (manually or using utility utilities), so it can be called directly from VBScript. See this article .
- Create a .NET executable that runs directly from VBScript.
- Using PowerShell to call into a .NET assembly and use VBScript to call PowerShell .
The easiest option on the website is to use GET or POST because you will avoid the ACL and COM registration minefields, but if you have to go the other way, I would say PowerShell is your best bet followed by COM interop as a third option.
+5
source to share
You need to mark your assembly as COM visible by setting the COMVisibleAttribute to true (either at the assembly level or at the class level if you only want to expose one type).
Then you register it with:
regasm /codebase MyAssembly.dll
and finally call it from VBScript:
dim myObj
Set myObj = CreateObject("MyNamespace.MyObject")
This question Originally Posted by Darin Dimitrov Here .
+1
source to share