Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2007

Tip: Looking for answers? Try searching our database.

Application settings, when is it deserialized?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
blekros - 24 Sep 2007 20:15 GMT
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
Kevin Spencer - 25 Sep 2007 11:06 GMT
Hi Brad,

When a DLl is sed by an application, it is running under the application's
context, and it is the application's configuration file that will be used.
Just add the necessary settings to the application's configuration file and
the DLL will use them.

Signature

HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

> Group,
>
[quoted text clipped - 158 lines]
>    End Module
> End Namespace
blekros - 25 Sep 2007 13:16 GMT
> Hi Brad,
>
[quoted text clipped - 4 lines]
>
> --

I was quite sure that this behavior was changed with .NET 2.0, and the
default behavior of VS2005 seems to agree when you add an application
configuration file to a .dll class library project.  Alas, confusion
reigns again.

I suppose I could customize my installer class to locate the
application.exe configuration and append my stuff to it somehow.  I'll
think on that...

But the application configuration file (.exe.config) will be
problematic as it's a commercial app, subject to reinstalls for
version upgrades.  It looks like I may have to go back to the
homegrown XML config file I started with in 1.1.  Of course, then I
have to manually edit my web-reference source code to look it up,
instead of just setting the "dynamic" property.

So close, yet so far.

Brad

> HTH,
>
[quoted text clipped - 165 lines]
> >    End Module
> > End Namespace

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.