my.Settings from referenced DLL

C

Craig Adams

Hi Everyone,
The my.Settings is a very nice addition to .net framework 2.0.

It is very easy to work with. However, I have not been able to figure out
how to access those user settings from a referenced dll in the same project.

If someone can point me in the right direction, I would appreciate it.

Thanks,
Craig Adams
Vivus Software, Inc.
 
M

[MSFT]

Hello Craig,

In your question, you mean do not know how to use my.Settings in your
Reference dll, Here an example on how to use it in reference dll:

Create your class library, Named Class1. and your own project named Post,

Imports System.Reflection
Imports System.Reflection.Assembly

Public Class Class1
Function Test() As String
'get your assembly by using GetCallingAssembly()
Dim assembly As Assembly =
System.Reflection.Assembly.GetCallingAssembly()
'get your my.settings type it always be YourNamespace.ClassName
Dim tt As Type = assembly.GetType("Post.My.MySettings")

Dim p As PropertyInfo
For Each p In tt.GetProperties()
'use constructor
Dim myconstructors() As ConstructorInfo = tt.GetConstructors()
'get field information
Dim myfields() As FieldInfo = tt.GetFields()

' get method infomation
Dim myMethodInfo() As MethodInfo = tt.GetMethods()

'get property infomation
Dim myproperties() As PropertyInfo = tt.GetProperties()
' get event infomation
Dim Myevents() As EventInfo = tt.GetEvents()
Next

Return ""
End Function
End Class

For detail use of Reflection and Assembly, you can go here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemreflectionassemblyclasstopic.asp

Hope this help,

Luke
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top