I have created the following com class in vb.net using VS 2010:
Then I created a new project with a form to test it. Here's the form code:
But when I call my function, I get System.EntryPoi ntNotFoundExcep tion
I've been googling for days with no results. I can't seem to find any kind of guide to telling me how to create a vb.net dll and call it from vb.net.
Thanks for your help.
Code:
<ComClass(AgileApi.ClassId, AgileApi.InterfaceId, AgileApi.EventsId)> _
Public Class AgileApi
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "38a4d038-7e0b-40f7-9299-4d7b18d5d25f"
Public Const InterfaceId As String = "aae5fd64-b9b2-497e-882c-006618d1679f"
Public Const EventsId As String = "fb928add-9053-46a7-b124-49183b1cea18"
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub
Public Function callAgile(ByVal protocol As String, ByVal host As String, ByVal port As Integer, ByVal serviceName As String, ByVal methodName As String, ByVal parms As String()) As String
Dim xml As String
Return xml
End Function
End Class
Code:
Imports System.Runtime.InteropServices
Public Class Form1
<DllImportAttribute("AgileApi.dll", EntryPoint:="callAgile", SetLastError:=True, CharSet:=CharSet.Unicode, _
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function callAgile(ByVal protocol As String, ByVal host As String, ByVal port As Integer, ByVal serviceName As String, ByVal methodName As String, ByVal parms As String()) As String
'This should use the DLL
End Function
Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
Dim protocol As String
protocol = "http"
Dim host As String
host = txtHostName.Text
Dim port As Integer
port = Val(txtPortNumber.Text)
Dim serviceName As String
serviceName = txtServiceName.Text
Dim methodName As String
methodName = txtMethodName.Text
Dim parms(5) As String
parms(0) = txtParm0.Text
parms(1) = txtParm1.Text
parms(2) = txtParm2.Text
parms(3) = txtParm3.Text
parms(4) = txtParm4.Text
Dim last As Integer
For ix As Integer = 4 To 0 Step -1
If parms(ix) = "" Then
last = ix
End If
Next
ReDim parms(last + 1)
Dim xml As String
xml = callAgile(protocol, host, port, serviceName, methodName, parms)
txtXml.Text = xml
End Sub
End Class
I've been googling for days with no results. I can't seem to find any kind of guide to telling me how to create a vb.net dll and call it from vb.net.
Thanks for your help.
Comment