如何从 VBScript 调用 C# DLL 函数 [英] How to call C# DLL function from VBScript

查看:24
本文介绍了如何从 VBScript 调用 C# DLL 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的脚本在服务器上,所以我没有可用的 UI 交互,必须使用 DLL 而不是控制台应用程序.

I have my script on server, so I do not have UI interaction available and have to use DLL instead of console application.

如何从 VBScript 调用 C# DLL 中的函数?

How to call a function in C# DLL from VBScript?

如何使我的 DLL 成为 COMVisible?我必须注册吗?

How do I make my DLL to be COMVisible? Do I have to register it?

推荐答案

您需要通过设置 COMVisibleAttribute 为真(在程序集级别或类级别,如果您只想公开一种类型).

You need to mark your assembly as COM visible by setting the COMVisibleAttribute to true (either at assembly level or at class level if you want to expose only a single type).

接下来你注册它:

regasm /codebase MyAssembly.dll

最后从 VBScript 调用它:

and finally call it from VBScript:

dim myObj
Set myObj = CreateObject("MyNamespace.MyObject")

这篇关于如何从 VBScript 调用 C# DLL 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆