B
blekros
Group,
Using VS2005, VB.NET and .NET 2.0 Framework, I have a built a
mylib.dll class library. It is registered for COM interop. I have an
associated app.config. I build mylib project and get mylib.dll,
mylib.tlb, and mylib.dll.config. So far, so good.
I change the value of my setting in mylib.dll.config, using notepad.
I run a container app, which loads the COM wrapper, which should load
the .dll.config file and initialize my settings instance from
the .ddl.config file at SOME time. When is this time?
When I use a method in the library, I expect it to load my manually-
edited application setting, but instead, the value is what the code
was compiled with. Specifically, the default value specified in the
attribute on the settings.designer.vb for the property I'm using.
Here is the entirety of the generated class, settings.vb:
Namespace My
'This class allows you to handle specific events on the settings
class:
' The SettingChanging event is raised before a setting's value is
changed.
' The PropertyChanged event is raised after a setting's value is
changed.
' The SettingsLoaded event is raised after the setting values are
loaded.
' The SettingsSaving event is raised before the setting values are
saved.
Partial Friend NotInheritable Class MySettings
End Class
End Namespace
Where is a load /deserialization method for the .dll.config? Where is
the other part of the partial class?
Below is the entirety of settings.designer.vb. Where is the load /
deserialization taking place?
Am I supposed to implement the SettingsLoaded event and read it from
the .dll.config XML myself?
This appears to be a singleton object instantiated with a "new"
statement. There is no constructor that loads any file that is
obvious.
I've been waiting for this feature for a few years and would love to
use it. But, I don't see how it works. I don't see how it CAN work.
And, in fact, it is observed NOT TO WORK! {weeping, teeth gnashing}
What have a missed? It has to be something simple and obvious.
Thanks in advance,
Brad
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:2.0.50727.832
'
' Changes to this file may cause incorrect behavior and will be
lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(),
_
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator",
"8.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)>
_
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings =
CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New
MySettings),MySettings)
#Region "My.Settings Auto-Save Functionality"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)>
_
Private Shared Sub AutoSaveSettings(ByVal sender As
Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown,
AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.SpecialSettingAttribute(Global.System.Configuration.SpecialSetting.WebServiceUrl),
_
Global.System.Configuration.DefaultSettingValueAttribute("http://
webservicehostname/virtualdirectory/LookupService.asmx")> _
Public ReadOnly Property
AWCDisplayDocumentCmd_remoteDocMgr_DBGateway() As String
Get
Return
CType(Me("AWCDisplayDocumentCmd_remoteDocMgr_DBGateway"),String)
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()>
_
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")>
_
Friend ReadOnly Property Settings() As
Global.AWCArcMapCommand.My.MySettings
Get
Return Global.AWCArcMapCommand.My.MySettings.Default
End Get
End Property
End Module
End Namespace
Using VS2005, VB.NET and .NET 2.0 Framework, I have a built a
mylib.dll class library. It is registered for COM interop. I have an
associated app.config. I build mylib project and get mylib.dll,
mylib.tlb, and mylib.dll.config. So far, so good.
I change the value of my setting in mylib.dll.config, using notepad.
I run a container app, which loads the COM wrapper, which should load
the .dll.config file and initialize my settings instance from
the .ddl.config file at SOME time. When is this time?
When I use a method in the library, I expect it to load my manually-
edited application setting, but instead, the value is what the code
was compiled with. Specifically, the default value specified in the
attribute on the settings.designer.vb for the property I'm using.
Here is the entirety of the generated class, settings.vb:
Namespace My
'This class allows you to handle specific events on the settings
class:
' The SettingChanging event is raised before a setting's value is
changed.
' The PropertyChanged event is raised after a setting's value is
changed.
' The SettingsLoaded event is raised after the setting values are
loaded.
' The SettingsSaving event is raised before the setting values are
saved.
Partial Friend NotInheritable Class MySettings
End Class
End Namespace
Where is a load /deserialization method for the .dll.config? Where is
the other part of the partial class?
Below is the entirety of settings.designer.vb. Where is the load /
deserialization taking place?
Am I supposed to implement the SettingsLoaded event and read it from
the .dll.config XML myself?
This appears to be a singleton object instantiated with a "new"
statement. There is no constructor that loads any file that is
obvious.
I've been waiting for this feature for a few years and would love to
use it. But, I don't see how it works. I don't see how it CAN work.
And, in fact, it is observed NOT TO WORK! {weeping, teeth gnashing}
What have a missed? It has to be something simple and obvious.
Thanks in advance,
Brad
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:2.0.50727.832
'
' Changes to this file may cause incorrect behavior and will be
lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(),
_
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator",
"8.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)>
_
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings =
CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New
MySettings),MySettings)
#Region "My.Settings Auto-Save Functionality"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)>
_
Private Shared Sub AutoSaveSettings(ByVal sender As
Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown,
AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.SpecialSettingAttribute(Global.System.Configuration.SpecialSetting.WebServiceUrl),
_
Global.System.Configuration.DefaultSettingValueAttribute("http://
webservicehostname/virtualdirectory/LookupService.asmx")> _
Public ReadOnly Property
AWCDisplayDocumentCmd_remoteDocMgr_DBGateway() As String
Get
Return
CType(Me("AWCDisplayDocumentCmd_remoteDocMgr_DBGateway"),String)
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()>
_
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")>
_
Friend ReadOnly Property Settings() As
Global.AWCArcMapCommand.My.MySettings
Get
Return Global.AWCArcMapCommand.My.MySettings.Default
End Get
End Property
End Module
End Namespace