I have my script on server, so I do not have UI interaction available and have to use DLL instead of console application.
我的服务器上有我的脚本,因此我没有可用的UI交互,必须使用DLL而不是控制台应用程序。
How to call a function in C# DLL from VBScript?
如何从VBScript中调用C#DLL中的函数?
How do I make my DLL to be COMVisible
? Do I have to register it?
如何让我的DLL变为COMVisible?我需要注册吗?
2 个解决方案
#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).
您需要通过将COMVisibleAttribute设置为true将程序集标记为COM可见(如果要仅显示单个类型,则在程序集级别或类级别)。
Next you register it with:
接下来你注册它:
regasm /codebase MyAssembly.dll
and finally call it from VBScript:
最后从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.
是的,您需要将ComVisible属性设置为true,然后使用regasm或regsvcs以及tlbexp注册程序集。然后你可以使用Server.CreateObject并通过。
#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).
您需要通过将COMVisibleAttribute设置为true将程序集标记为COM可见(如果要仅显示单个类型,则在程序集级别或类级别)。
Next you register it with:
接下来你注册它:
regasm /codebase MyAssembly.dll
and finally call it from VBScript:
最后从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.
是的,您需要将ComVisible属性设置为true,然后使用regasm或regsvcs以及tlbexp注册程序集。然后你可以使用Server.CreateObject并通过。