Re: Config File Project Output: Did they change this in 2005?
- From: "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@xxxxxxx>
- Date: Mon, 20 Jun 2005 09:21:02 -0500
stand__sure,
Check the properties of you app.config file in solution explorer.
There is a new option that indicates Copy or Copy if Newer. I noticed it on
Sql Server 2005 Express data files.
It sounds like your app.config may be set to Copy if Newer, instead of
always copying...
Hope this helps
Jay
"stand__sure" <stand__sure@xxxxxxxxxxx> wrote in message
news:1119252354.584445.323430@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|I had occasion tonight to write an installer class that changed
| something in a config file tonight (I had never had a need to do it,
| but happened upon a "How To" article that explained it in terms of a
| web app and decided to try it with a regular app). What I discovered
| was that for some reason the .config file is not being copied with
| Primary Output. In checking a few other apps for which I had written
| installers I found that they too lacked .config files. I could have
| sworn that 2003 deployed these automatically -- am I wrong?
|
| Here is the custom installer class that I used (it's just a tweek of
| the m$ code)
|
| Imports System.ComponentModel
| Imports System.Configuration.Install
|
| Public Class WebServiceInstaller
|
| Public Overrides Sub Install( _
| ByVal stateSaver As System.Collections.IDictionary)
| MessageBox.Show("Started")
| Dim installlog As New System.IO.StreamWriter("c:\Installation.log")
| installlog.AutoFlush = True
| Try
| Dim ProvidedName As String =
| Me.Context.Parameters.Item("ServerName")
| Dim ServiceName As String =
| Me.Context.Parameters.Item("ServiceName")
| installlog.WriteLine("Starting edit of config file")
| If (String.IsNullOrEmpty(ProvidedName) _
| OrElse String.IsNullOrEmpty(ServiceName)) Then
| Throw New InstallException("No arguments specified")
| End If
|
| 'use reflection to find config file
| Dim assem As System.Reflection.Assembly = _
| System.Reflection.Assembly.GetExecutingAssembly()
| Dim strConfigLoc As String = assem.Location
| installlog.WriteLine(strConfigLoc)
|
| Dim strTemp As String = strConfigLoc
| strTemp = strTemp & ".config"
|
| Dim finfo As New System.IO.FileInfo(strTemp)
| installlog.WriteLine("File Info: " & strTemp)
| If (Not finfo.Exists) Then
| Throw New InstallException("Missing config file")
| installlog.WriteLine("Missing config file")
| Exit Sub
| End If
|
| 'load document into xml dom
| Dim xmldoc As New System.Xml.XmlDocument()
| xmldoc.Load(finfo.FullName)
|
| 'find the right node and change the value
| Dim nod As System.Xml.XmlNode
| Dim FoundIt As Boolean = False
| For Each nod In xmldoc.Item("configuration").Item("appSettings")
| 'skip comments
| If nod.Name = "add" Then
| If (nod.Attributes.GetNamedItem("key").Value = _
| "CryptoWebServiceConsumer.CryptoWS.Service") Then
| nod.Attributes.GetNamedItem("value").Value = _
| "http://" & ProvidedName & "/" & ServiceName & "/Service.asmx"
| FoundIt = True
| End If
| End If
| Next nod
|
| If (Not FoundIt) Then
| Throw New InstallException("Config file did not contain a
| ServerName section")
| End If
|
| xmldoc.Save(finfo.FullName)
| Finally
| installlog.WriteLine("Ending edit of config file")
| installlog.Close()
| End Try
| End Sub
| End Class
|
.
- Follow-Ups:
- Re: Config File Project Output: Did they change this in 2005?
- From: stand__sure
- Re: Config File Project Output: Did they change this in 2005?
- References:
- Config File Project Output: Did they change this in 2005?
- From: stand__sure
- Config File Project Output: Did they change this in 2005?
- Prev by Date: Re: Listbox problems
- Next by Date: Create Executable and install file
- Previous by thread: Re: Config File Project Output: Did they change this in 2005?
- Next by thread: Re: Config File Project Output: Did they change this in 2005?
- Index(es):
Relevant Pages
|