Question

I'd like to execute a .NET dll file from vbscript in a synchronous way - is this possible? if yes, is it possible to execute a GAC assembly?

thanks, Ofer

Was it helpful?

Solution

I think you must first make the .NET assembly COM-visible by including the ComVisible attribute in the AssemblyInfo.cs file:

[ComVisible(true)]

See this page on MSDN: Packaging an Assembly for COM

And then in VBScript you can access those components by the same means you access COM components, i.e. using CreateObject or Server.CreateObject as in:

Set testObj = CreateObject("MyNamespace.MyType")

I think GAC might even be mandatory to access it from VBScript but I havn't done it this way around so I'm not sure.

Why would you want to do that in VBScript? Why not just make a .NET console application that would do what your VBScript was meant to do? Since the DLL is already on .NET, that shouldn't be a problem, right?


EDIT: Another way to do this might be to create a console EXE instead of a DLL (or an EXE that wraps up a DLL) that you can call from VBScript like a normal executable program and examine return results. Depending on many factors, this might be more flexible than maintain COM code.

OTHER TIPS

VBScript can only execute code from COM objects, so you would need to create a COM wrapper for your .NET code and then you should be able to call your .net code.

Not directly.

If the .NET assembly was exposed as a COM component, then it could be.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top