Hi,
I am trying to interface my microcontroller with ASP.net in Web Form but have met with some difficulties.
My coding is working correctly in VB Windows Form but once ported to ASP.net Web form, it encounters error.
Basically, im taking in 2 inputs from microcontroller and update the Web Form through use of serial port.
Below is my coding for VB
<br />
Imports System<br />
Imports System.IO.Ports<br />
Imports System.Threading.Thread<br />
Imports System.ComponentModel<br />
<br />
Public Class frmMain<br />
<br />
Dim WithEvents Serialport7 As New IO.Ports.SerialPort<br />
<br />
Public Delegate Sub MyDelegate(ByVal ReceivedData As String)<br />
<br />
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
<br />
With Serialport7<br />
.PortName = "Com7"<br />
.BaudRate = 9600<br />
.Parity = Parity.None<br />
.DataBits = 8<br />
.StopBits = StopBits.One<br />
End With<br />
<br />
Try<br />
Serialport7.Open()<br />
Catch ex As Exception<br />
MsgBox(ex.ToString)<br />
End Try<br />
<br />
End Sub<br />
<br />
Private Sub Serialport7_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles Serialport7.DataReceived<br />
<br />
Me.BeginInvoke(New MyDelegate(AddressOf DisplayReading), Serialport7.ReadLine)<br />
<br />
End Sub<br />
<br />
Private Sub DisplayReading(ByVal ReceivedData As String)<br />
<br />
If ReceivedData.Substring(0, 1) = "T" Then<br />
<br />
RichTextBox1.Text = ReceivedData.Remove(0, 1)<br />
<br />
ElseIf ReceivedData.Substring(0, 1) = "H" Then<br />
<br />
RichTextBox2.Text = ReceivedData.Remove(0, 1)<br />
<br />
End If<br />
<br />
RichTextBox3.Text = System.DateTime.Now<br />
<br />
End Sub<br />
<br />
Private Sub MyFormClosing(ByVal sender As Object, ByVal e As ComponentModel.CancelEventArgs) Handles MyBase.Closing<br />
<br />
If Serialport7.IsOpen Then Serialport7.Close()<br />
<br />
End Sub<br />
<br />
End Class<br />
The error being
<br />
'BeginInvoke' is not a member of '_Default'<br />
How can i resolve this ?
Can anyone tell me how do i port the codes correctly from Window form to a Web form ?
I seek anyone's help earnestly.
Thanks.