开发者

Access MySettings from other Project in Solution

Is it possible to access the My.Settings of an other DLL referenced in the current Project? I have a Database project in wh开发者_StackOverflow中文版ich Settings the ConnectionString is stored. I need access to this Setting in an other Project(for Log-File).


I have helped myself by a class in the Database-Project which has a function getAppSetting:

Public NotInheritable Class Helper
   Private Sub New()
   End Sub

   Public Shared Function getAppSetting(ByVal key As String) As String
       Dim returnValue As Object = My.Settings(key)
       If returnValue Is Nothing Then
           Return String.Empty
       Else
           Return returnValue.ToString
       End If
   End Function
End Class

I can call this function from my other project to get f.e. the ConnectionString.


Have you tried looking at something like the System.Configuration.ConfigurationManager, I know it works for web apps, not sure about database projects.

Then you could get your connection string with a command like:

ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString

http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜