Al Reid said:
Why should this be so hard? I don't have an answer to that, but I did
find a temporary work-around that I don't feel completely
comfortable with.
I created my own XML configuration file that I will distribute with the
COM dll that contain the web reference. I then manually
edited the settings.designer.vb file to make the existing entry for the
dynamic web reference read/write. I then coded a class to
retrieve the setting from the custom xml file and to write the setting to
the my.settings.xxxx setting. The new setting is then
automatically used when I create the reference to the web service.
I would have preferred finding a way to just load the *.dll.config file,
but so far no luck.
I'll continue to monitor this thread for a while and hope that there is
someone with an answer.
Thanks,
I solved it with this class that i include in all my dll projects
Imports System.Configuration
Namespace My
Partial Friend NotInheritable Class MySettings
Private DllSettings As ClientSettingsSection
Private DllConfigDoesNotExist As Boolean
Default Public Overrides Property Item(ByVal propertyName As String)
As Object
Get
Dim oValue As Object = Nothing
Try
'If the .dll.config file has already been loaded, use it
to obtain the value...
If DllSettings IsNot Nothing Then
oValue =
DllSettings.Settings.Get(propertyName).Value.ValueXml.InnerXml
ElseIf Not DllConfigDoesNotExist Then
If Me.LoadDllConfigFile() Then
oValue =
DllSettings.Settings.Get(propertyName).Value.ValueXml.InnerXml
End If
End If
Catch ex As Exception
End Try
Try
If oValue Is Nothing Then
oValue = MyBase.Item(propertyName)
End If
Catch ex As Exception
End Try
Return oValue
End Get
Set(ByVal value As Object)
MyBase.Item(propertyName) = value
End Set
End Property
Private Function LoadDllConfigFile() As Boolean
Dim bDllConfigLoaded As Boolean = False
Dim cfgDll As System.Configuration.Configuration
Dim cfmDllCfg As New ExeConfigurationFileMap()
Dim sAssemblyPath As String =
Reflection.Assembly.GetExecutingAssembly().Location
Dim strNamespace As String = GetType(MySettings).FullName
strNamespace = strNamespace.Substring(0,
strNamespace.IndexOf("."c))
cfmDllCfg.ExeConfigFilename = sAssemblyPath & ".config"
Try
cfgDll =
ConfigurationManager.OpenMappedExeConfiguration(cfmDllCfg,
ConfigurationUserLevel.None)
Dim csgApplicationSettings As ConfigurationSectionGroup =
cfgDll.GetSectionGroup("applicationSettings")
Me.DllSettings =
DirectCast(csgApplicationSettings.Sections(strNamespace & ".My.MySettings"),
ClientSettingsSection)
bDllConfigLoaded = True
Catch ex As Exception
'bestaat niet
DllConfigDoesNotExist = True
End Try
Return bDllConfigLoaded
End Function
End Class
End Namespace
HTH
Michel Posseth