Re: VB.NET COM DLL form a VBScript

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



OK I solved the problem.
Thanks to everyone who wrote me.
This is the solution:

----BEGIN OF CODE-------
Public Class Class1

Public Sub Importa(ByRef visum As Object, ByVal numPF as Integer)
Dim VisumCl as Object = visum
VisumCl.Net.Marking.Clear()
Dim spp as Object = VisumCl.Net.Marking
spp.Add(Ctype(VisumCl.Net.StopPoints.ItemByKey(numPF), Object))
End Sub

Public Sub New()
MyBase.New()
End Sub

End Class
--------------------END OF CODE------

As you can see, before adding an element
VisumCl.Net.StopPoints.ItemByKey(numPF) to the container
VisumCl.Net.Marking, I have to convert it to generic type Object. Now
all works correctly!

Obviously from the VBScript I execute the statements:

Set dllobject = CreateObject("ClassLibrary1.Class1")
dllobject.Importa comobjectname numPF

Moreover, I added the dll: ClassLibrary1.dll and Interop.VISUMLIB.dll
in the
main directory where I execute the VBScript and where is located the
VISUM.EXE (dependence of Interop.VISUMLIB.dll)

Thank to everyone who answered me!
.