none
manual changes in app.dll.config are not reflecting RRS feed

  • Question

  • Hi,

    I am developing an addin for outlook 2007 using visual studio 2010, this project also involve app.config file.

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
            <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
                <section name="DDLMSOI2007PU2010.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
            </sectionGroup>
        </configSections>
    	<appSettings>
    		<add key="roombooking" value="123"/>
    	</appSettings>
        <system.diagnostics>
            <sources>
                <!-- This section defines the logging configuration for My.Application.Log -->
                <source name="DefaultSource" switchName="DefaultSwitch">
                    <listeners>
                        <add name="FileLog"/>
                        <!-- Uncomment the below section to write to the Application Event Log -->
                        <!--<add name="EventLog"/>-->
                    </listeners>
                </source>
            </sources>
            <switches>
                <add name="DefaultSwitch" value="Information" />
            </switches>
            <sharedListeners>
                <add name="FileLog"
                     type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
                     initializeData="FileLogWriter"/>
                <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
                <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
            </sharedListeners>
        </system.diagnostics>
        <applicationSettings>
            <DDLMSOI2007PU2010.MySettings>
                <setting name="CodeSite" serializeAs="String">
                    <value>Selene:3434</value>
                </setting>
                <setting name="DatacraftRoomBookingURL" serializeAs="String">
                    <value>http:\\portia:9099\dwsapps-v1\outlook.aspx</value>
                </setting>
                <setting name="Logfile" serializeAs="String">
                    <value>Codesite</value>
                </setting>
                <setting name="EnableContextMenu" serializeAs="String">
                    <value>True</value>
                </setting>
            </DDLMSOI2007PU2010.MySettings>
        </applicationSettings>
    </configuration>

    when i deploy the project, it creates a DDLMSOI2007PU2010.dll.config file in installation directory. when i change any setting in this file manually and then  i restart outlook,new changes do not reflect ,for example if i change the Logfile setting to Codesite4 , it do not reflect when i restarted outlook. it still saying value as Codesite.

    Note that my addin on target machine works fine other than this issue.

    one thing which i am also not sure why it is happening. in above configuration file i created <appSettings> section,when i deploy the addin project and restart outlook on the target machine,ConfigurationManager.AppSettings.Keys.Count is coming out to zero , however when i debug on developer machine it's coming out to 1.

    Also, when i deploy the same project using visual studio 2005, making changes in app.dll.config are reflecting.

    just to make sure, if this is a mechanism for deploying with visual studio2010, i just created a simplest window form application and added a app.config in it,i deployed the project on same target machine, it created a file windowformapplication.exe.config file in installation directory(c:\Progarm files...), now whenever i make change in the settings, it always reflects.

    note that, i am not making any changes programmatically, i am changing settings manually, by opening in dll.config file stored in installation directory.

    Anyone have idea, why its happening with outlook addin projects but not with window form application? is there any difference in mechanism.

    I am really stuck with this ..

    Thanks


    Wednesday, February 29, 2012 9:44 AM

Answers

  • As for WinForms app - no problem since VSTOR is not involved and (most probably since i did not check this) ShadowCopyFiles is not set on AppDomain that is used to run code. As for difference between VS2005 and Vs2010 - both require different VSTOR versions to run add-in so changes most probably are there. But if you can go with hand rolled approach then i guess you will be fine. Please close this thread unless you want to investigate why VSTOR behaves in such way.
    • Marked as answer by Nitrup Wednesday, February 29, 2012 1:24 PM
    Wednesday, February 29, 2012 12:28 PM

All replies

  • It is an old problem with standard settings functionality files and VSTOR - basically when starting up outlook, VSTOR 'caches' your files to some temporary directory under your %HOME% dir, so as you may have already guessed - your changes made in %PROGRAMFILES% may not necessarily be 'loaded' because VSTOR may decide that local 'cache' is still fresh. Try to determine if doing your manual changes changes last modification date on config file.
    Wednesday, February 29, 2012 9:56 AM
  • Hi Damian,

    Are you asking me check last modification time for config file i am changing at installation directory?

    if that is so, then i checked and  its changing.

    anyhow, is there anyway to make sure it always pick latest changes made at installation directory or some thing like i can clear the cache?

    Thanks

    Wednesday, February 29, 2012 10:19 AM
  • I have never used those standard user settings functionality, i always rolled my own config file with custom name and used (for example) XMLSerialization to dehydrate its contents into config data class. Make simple test, deploy with your add-in simple file: test1.config. In add-in read its contents using File.ReadAllText("test1.config") and display it or log somewhere. Now make manual change in that file and determine if changes are visible on next add-in start.
    Wednesday, February 29, 2012 10:29 AM
  • yes, it does..

    i am already doing it by using

    Dim file As String = AppDomain.CurrentDomain.BaseDirectory & "\DDLMSOI2007PU2010.dll.config"

    Dim url As String = GetSettings("DatacraftRoomBookingURL")
                Dim logfile As String = GetSettings("Logfile")
                Dim codesite As String = GetSettings("CodeSite")

    Private Function GetSettings(ByVal key As String) As String
            Dim xmldoc As New XmlDocument
            Dim xmlnode1 As XmlNodeList
            xmldoc.Load(file)
            xmlnode1 = xmldoc.SelectNodes("/configuration/appSettings/add[@key='" & key & "']")
            Dim childnode As XmlNode = xmlnode1.Item(0)
            Dim v1 As XmlAttributeCollection = childnode.Attributes
            Dim xc As XmlAttribute = v1.ItemOf("value")
            GetSettings = xc.Value
        End Function

    this is working fine , whenever  i make a change manually.

    I am just wondering, what's going wrong with standard functionality. it always working when i deploy the project developed using visual studio 2005, but when i developed a new addin  project in visual studio 2010 and deployed it, manual changes never reflects. however if i deployed a window form application developed in vs 2010, it always pick manual changes made in app.exe.config.

    but as you said , it is an old problem with standard settings functionality files and VSTOR.

    if there is no way to get rid of this, i will probably go for above approach then.

    Thanks

    Wednesday, February 29, 2012 11:38 AM
  • As for WinForms app - no problem since VSTOR is not involved and (most probably since i did not check this) ShadowCopyFiles is not set on AppDomain that is used to run code. As for difference between VS2005 and Vs2010 - both require different VSTOR versions to run add-in so changes most probably are there. But if you can go with hand rolled approach then i guess you will be fine. Please close this thread unless you want to investigate why VSTOR behaves in such way.
    • Marked as answer by Nitrup Wednesday, February 29, 2012 1:24 PM
    Wednesday, February 29, 2012 12:28 PM