Results 1 to 3 of 3

Thread: Set and get properties of Shared Libraries (.dll)

  1. #1

    Thread Starter
    Addicted Member ryanframes's Avatar
    Join Date
    Apr 2012

    Set and get properties of Shared Libraries (.dll)

    I created comp.dll for my project and then add the dll to my projects.sln (multiple projects), for every project on projects.sln i added comp.dll to its References, and created 1 mdlmain.vb

    Module mdlMain
        Public master_FA As New master_FixAsset
        Public objComp As New component.clsFunction
    End Module
    and 1 clsmain.vb to call main form on that project.

    in comp.dll i made a property :

    Private pubUserName as String    
        Public Property userName As String
                Return pubUserName
            End Get
            Set(value As String)
                pubUserName = value
            End Set
        End Property
    i changed the properties through my login.vbproj (inside projects.sln), but when i tried to get the value of that properties (from fixasset.vbproj) it returns nothing. Is it because i declare New component.clsFunctionin fixasset.vbproj so the compilers (?) create another new object in my .sln ? How can i fix this ?

    Sorry for bad english.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    Re: Set and get properties of Shared Libraries (.dll)

    There are no objects in your solution. Your solution (more correctly, the projects in your solution) contains types. An object is an instance of a type. Each type can have as many instances as you like and each one is a distinct object. Just as in real life, you and I are both instances of the Person type and any changes made to one of us has no direct effect on the other, so it is with programming objects. If you create two instances of your type then changing a property value for one will have no effect on the other.

    If you want a property to have a single value for the type that all instances can access then you need to declare that property Shared. Even then though, that property value is still unique to each application domain, so two apps accessing that property will still see two separate values. The same goes for the same app accessing the property over two different runs.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member ryanframes's Avatar
    Join Date
    Apr 2012

    Re: Set and get properties of Shared Libraries (.dll)

    so , how to create some 'public variable' that every projects on my solution can access it ? can we create public variables in one solution(.sln) that every projects on that solution can access ?

    i added Settings variables(Project Properties->Settings) on comp.dll and it did the trick, i just wondering if there're better solution out there (because my knowledge limitation on vbnet)
    Sorry for bad english.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width