如何从VBScript调用.NET DLL? [英] How to call a .NET DLL from a VBScript?

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

问题描述

我将此代码从visual studio转换为dll并注册它但我不能使用vbs代码来使用它甚至用vbs代码重写它



i make this code into dll from visual studio and register it but i cant make a vbs code to use it or even rewrite it in vbs code

Dim hostname As IPHostEntry = Dns.GetHostEntry("www.google.com")
Dim ip As IPAddress() = hostname.AddressList
Debug.Print(ip(0).ToString())

推荐答案

此代码必须位于暴露于COM的库中。您不能创建普通的类库项目,并期望它在VBScript中工作。它必须是一个暴露于COM的库。



接下来,必须使用REGASM注册该库,该文件位于C:\ Windows \ microsoftoft.NET文件夹下。 REGSVR32将无法工作!



之后,在您的VBScript coede中,您必须使用CreateObject创建类的实例,然后才能调用您在库中的类代码。
This code has to be in a COM-exposed library. You can NOT create a normal class library project and expect it to work in VBScript. It MUST be a COM-exposed library.

Next, the library has to be registered using REGASM, found under C:\Windows\Microsoft.NET folders. REGSVR32 WILL NOT WORK!

After that, in your VBScript coede, you have to create an instance of your class using CreateObject before you can call the methods you exposed in your class code in the library.


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

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