how to create a dl of a window application, step by step

Dani AI

Generated

Short answer: a Windows Forms "Application" project builds an EXE. To produce a DLL you should move the reusable parts into a Class Library (an assembly). A Class Library can contain classes, modules, user controls or forms, but it cannot start the application message loop — the host EXE must instantiate and run any forms.

Step-by-step (practical):

  1. Create a new Visual Basic Class Library project targeting the same .NET framework as the consuming app.
  2. Move business logic, modules and (optionally) forms or user controls into that project.
  3. Make types you want to use from other projects Public (for forms set the Form's Modifiers property to Public).
  4. Build the Class Library to get the DLL (bin\Debug or bin\Release).
  5. Reference the DLL from the consuming project (Add Reference -> Projects or Browse).

Example utility class and usage:

' In Class Library
Public Class Utilities
    Public Shared Function Add(a As Integer, b As Integer) As Integer
        Return a + b
    End Function
End Class

' In consuming EXE
Dim n = Utilities.Add(2, 3)

Sharing Forms or Controls:

  • For reusable UI prefer UserControl so it can be dropped on a form or added to the toolbox (Tools -> Choose Items -> Browse -> select DLL).
  • To show a form that lives in the DLL, the host creates an instance:
' In consuming EXE
Dim f As New SharedForm()
f.ShowDialog()

Troubleshooting & notes:

  • Keep both projects on the same .NET target.
  • If designer-generated classes are Friend, change Modifiers to Public or edit the class declaration.
  • Libraries cannot run Application.Run or My.Application startup code; move that to the EXE.
  • If building a plugin system, put shared interfaces in a small shared assembly and load implementations from DLLs via reflection.

This expands on 's pointer with concrete steps for and agrees with that external guides are useful while showing the key gotchas to watch for.

Recommended Answers

All 2 Replies

thanks. great site for me...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.