-
Feb 2nd, 2018, 08:24 PM
#1
Thread Starter
Addicted Member
Set and get properties of Shared Libraries (.dll)
Hello,
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
Code:
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 :
Code:
Private pubUserName as String
Public Property userName As String
Get
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 ?
Thanks.
Sorry for bad english.
-
Feb 2nd, 2018, 10:51 PM
#2
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.
-
Feb 3rd, 2018, 01:09 AM
#3
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|