473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Can VB.Net DLL Have Specific Controls With No Form?

I am very new to .Net and Visual Basic in general. My goal is to write
a Visual Basic .Net DLL that can have its functions and subroutines
called from another .Net application. My DLL will not have any kind of
user interface.

Can I use a Timer Control, A Winsock Control, and Serial Com Port class
(The reason I am using this class from some borrowed code, is that I
heard that .Net 1.1 does not have a built-in Serial Com Port
Communication class) in my DLL without using a form?

Thanks for any guidance on if this is even possible in .Net

Jean-Marie Vaneskahian
je**@vaneskahian.com

Aug 13 '05 #1
3 3111
Jean,

A control has in Net two meanings, for most of us it is all that inherits
from "control" (either Webpage or Winform). For others it is as well a kind
of component as it is used in the toolbox (this misunderstanding is probably
because how Microsoft uses that toolbox and the way they describe it).

A (kind of) component can you use (almost) everywhere. A control you can of
course only use with a form. (While a windowforms timer can only be used
with a form, however there are two other timers that can be used on other
places).

I hope this helps,

Cor
Aug 14 '05 #2
Though I am not exactly sure of how thinks happen in vb.net, I more or less have a C# background, I would attempt to answer your question.

If the controls that you plan to use makes it a requirement that they be hosted on a windows form, you can add a form to your project and still compile the entire application as a .NET class library (.dll), you can keep this form hidden or something after you load it. And by the way the controls mentioned by you can also be used without adding them to a form:

dim oSocket as new WinSocketControl
..
..
..
oSocket.Listen()

HTH, Metallikanz!
<je**@vaneskahian.com> wrote in message news:11**********************@g49g2000cwa.googlegr oups.com...
I am very new to .Net and Visual Basic in general. My goal is to write
a Visual Basic .Net DLL that can have its functions and subroutines
called from another .Net application. My DLL will not have any kind of
user interface.

Can I use a Timer Control, A Winsock Control, and Serial Com Port class
(The reason I am using this class from some borrowed code, is that I
heard that .Net 1.1 does not have a built-in Serial Com Port
Communication class) in my DLL without using a form?

Thanks for any guidance on if this is even possible in .Net

Jean-Marie Vaneskahian
je**@vaneskahian.com

Aug 14 '05 #3
Here is a posting I made on the HomeSeer message board. I now have the
answers to many of my questions.

Guys thanks so much for the information. Since I posted this question I
have bought myself the two Wrox books on Visual Basic .Net (Beginning
and Programming). I have skipped around in the books looking for the
information I would need to build my code natively in .Net.

Through my previous experience with VB 6.0 writing an ActiveX
Executable that talked to HomeSeer 1.7 through COM and vice-versa, and
the answers to my questions here, I now have all the information I
need.

I do like the idea of writing my code as HomeSeer Plug-In since I would
be in the same "environment" as HomeSeer itself with all the
benefits that provides. Since my code will not have any kind of user
interface and I would just like to make this a .Net class, I would like
to write the code as a DLL.

The big three controls that I used to use were the MSComm Control,
Winsock Control and Timers on forms. I have learned the basics of all
three of these in .Net and how they would be imbedded in a .Net class
or as classes of their own called by my .Net class.

Here is what I have done for my three main components:

1. For serial port communications I am using the code posted here by
Rich. It is a .Net Class that looks like a wrapper for calls to the
Windows API. I have compiled the class called "clsRS232" as a DLL
in Visual Studio 2003. It seems to have the events and properties that
I will need, similar to the MSComm Control in Visual Basic 6.0.

2. For Winsock communications (specifically UDP) I have built my own
..Net class that I have compiled into a DLL. Here is the source code for
the class I wrote (it has an event and a few methods), it works great.
Code:
Imports System.Net.Sockets
Imports System.Text
Imports System.Threading
Public Class UDPData
Private ReceivingUDPObject As UdpClient
Private ThreadUDPReceive As System.Threading.Thread
Private RemoteIpEndPoint As New
System.Net.IPEndPoint(System.Net.IPAddress.Any, 0)
Public Event UDPMessageReceived(ByVal Message As String)
Public Sub SendDataViaUDP(ByVal LocalPort As Integer, ByVal
RemoteComputerAddress As String, ByVal RemoteComputerPort As Integer,
ByVal Message As String)
Dim UDPClientObject As New UdpClient(LocalPort)
UDPClientObject.Send(Encoding.ASCII.GetBytes(Messa ge),
Encoding.ASCII.GetBytes(Message).Length, RemoteComputerAddress,
RemoteComputerPort)
UDPClientObject.Close()
UDPClientObject = Nothing
End Sub
Public Sub StartReceivingUDPData(ByVal ListenToPort As Integer)
ReceivingUDPObject = New System.Net.Sockets.UdpClient(ListenToPort)
ThreadUDPReceive = New System.Threading.Thread(AddressOf
ReceiveUDPMessages)
ThreadUDPReceive.Start()
End Sub
Public Sub StopReceivingUDPData()
ThreadUDPReceive.Abort()
ReceivingUDPObject.Close()
End Sub
Private Sub ReceiveUDPMessages()
Dim RawDataReceived As [Byte]() =
ReceivingUDPObject.Receive(RemoteIpEndPoint)
Dim StringReceived As String
StringReceived = Trim(Encoding.ASCII.GetChars(RawDataReceived))
RaiseEvent UDPMessageReceived(StringReceived)
StartNewUDPReceivingThread()
End Sub
Private Sub StartNewUDPReceivingThread()
ThreadUDPReceive = New System.Threading.Thread(AddressOf
ReceiveUDPMessages)
ThreadUDPReceive.Start()
End Sub
End Class
3. For timed events to fire off, I learned how to use timers in a
class. It is very different from the simple little timer control you
add to your forms in Visual Basic 6.0, but again they work just fine.
Code:
Private WithEvents TestTimer As Timers.Timer
Private Ticks As Integer

Sub Start_Timer()
TestTimer = Nothing
TestTimer = New Timers.Timer
TestTimer.Interval = 1000
TestTimer.Start()
End Sub

Private Sub TestTimer_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles TestTimer.Elapsed
Console.WriteLine("Tick: " & Ticks)
Ticks += 1
If Ticks > 5 Then
Ticks = 0
TestTimer.Stop()
End If
End Sub
I have completely read the HomeSeer Plug-In SDK and think I understand
what I need to do. At the very least I can get my DLL working and then
deal with the HomeSeer Plug-In issues. I am curious, what is the
difference from an event that a .Net Class fires off and what HomeSeer
calls "Callbacks"? What are Callbacks and why do they have to be
registered and where would I use them? If my process does some
listening on the Serial port and some UDP messages with some looping,
when should I call the equivalent of DoEvents in .Net or use the new
"Threading"?

Thanks again for all your help, and any more guidance or suggestions
would be greatly appreciated!

Jean-Marie Vaneskahian
je**@vaneskahian.com

Aug 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: lawrence | last post by:
Is this the correct way to test for a method before I use it? createRange() is, I believe, an IE only method. function wrapSelectionInTag(selection, tag) { if (document.selection.createRange)...
1
by: Dave | last post by:
Hello, I've been waisting tons of time on this, so I'll just ask and hopefully someone will be able to help. I am opening an excel document and placing values into it's "letterhead" section...
7
by: TDIOwa | last post by:
I have a form that has a specific date on it. I want to open another form that has the Active Control Calendar on it. I want to open this form to the specific date on the first form. I have...
1
by: Stefan W via .NET 247 | last post by:
I'm relatively new to C#, (I have to use it, now that I'veinherited someone else's projects). I'm looking for a way toiterate through the controls on a form; if the control is of acertain type, I...
2
by: Hawk | last post by:
I have a custom menu control that I am creating using C#. I am rendering HTML from a StringBuilder in my control to add the needed JavaScript to the HTML output. I need to have the JavaScript...
5
by: jean | last post by:
I am very new to .Net and Visual Basic in general. My goal is to write a Visual Basic .Net DLL that can have its functions and subroutines called from another .Net application. My DLL will not...
2
by: Frank | last post by:
I created this test routine to return the form containing a certain input element: function GetElementForm(element) { // Return the form that contains element. var myElement = element; ...
0
by: Amigo | last post by:
Hello all! I have just started learning C# a couple of weeks ago. I went through a few tutorials and now I am thinking of starting a real application to learn it better. The application is a...
3
by: Darin | last post by:
I have a form that might (or might not) have a textbox on it named something particular - how can I find if the form has the control, and if it does what the text of the control has? This form has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.