Public variables not visible in DLL

Aarvee

Well-known member
Joined
Sep 21, 2005
Messages
50
Location
Bangalore, India
Programming Experience
Beginner
Hi ! I need some help in the above subject.I have a Winforms application in which there is a Module which declares some variables as Public. In any of the forms in the project, I am able to access these variables without specifically passing the same to the form. Also in any of the functions in the module, the same are visible without passing them as parameter.Now I have also written a class module and compiled it as DLL in which these public variables are referred to. I have put Option Explicit Off in the class module and compiled the same. Another input is the functions in the DLL are Public shared.When I add the reference of this DLL into my project and call any of the functions in the DLL, the values of all the public variables referred to becomes "nothing" even though in the calling project they do have values.I do not know whether there is any error in my approach. To overcome this, currently I pass all the relevant public variables to the functions in the DLL. With this workaround I am not having any problem. But I would like to know whether there is a simpler and more elegant way of doing this.Thanks for the help.Varadarajan R
 
i would use public properties to access the variables instead of having the variables be public

by using properties you can validate the data before setting the variable

VB.NET:
Private m_FirstName As String

Public Property FirstName As String
  Get
    Return m_FirstName
  End Get
  Set (value As String)
    If value <> String.Empty Then
      'Make sure name isnt nothing
      m_FirstName = value
    End If
  End Set
End Property

but as far as your problem of the variables not being seen, i dont have any idea
 
Back
Top