How to call C# DLL function from VBScript

不想你离开。 提交于 2019-12-17 04:32:13

问题


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

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

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


回答1:


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).

Next you register it with:

regasm /codebase MyAssembly.dll

and finally call it from VBScript:

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



回答2:


Yes you will need to set the ComVisible attribute to true and then register the assembly using regasm or regsvcs along with tlbexp. Then you can use Server.CreateObject and sail through.



来源:https://stackoverflow.com/questions/769332/how-to-call-c-sharp-dll-function-from-vbscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!