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

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

问题描述

我有我的服务器上的脚本,所以我没有用户界面交互使用并有能力使用,而不是控制台应用程序的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?

推荐答案

您需要通过设置<一个标记您的程序集作为COM可见href=\"http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.comvisibleattribute.aspx\">COMVisibleAttribute为true(无论是在装配级或类级别,如果你想要公开只有一个类型)。

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天全站免登陆