ClickOnce and app.config file
I have a new WinForms application that I'm trying to deploy with the ClickOnce method. However, the app.config file that is needed for the application is not included with the installation.
The application is installed properly from the server, and launches the exe, but as soon as I try to login by hitting my WCF Server, I get.
"Could not find the file 'C:\Documents and Settings\Adminstrator\Local Settings\Apps\2.0\7KAA3h20\app.config"
I can manually copy the file from my development machine to this folder and the application works fine.
Any ideas?
Re: ClickOnce and app.config file
That's because it's not called app.config.... sounds like you're trying to access the file directly, rather than use the built-in methods. After compiling, look in the bin/debug or bin/release folders .... you'll find that the config file is application_name.config ....
-tg
Re: ClickOnce and app.config file
Interesting,
I remembered I had a function that uses the app.config file in xdocument to identify my Web Service endpoints. My reference to it is hard coded. I also have a couple of other files that I reference in a similar way that are relocated with the ClickOnce installation.
Code:
Public Shared Function GetServiceEndpoint(ByRef InterfaceType As String) As String
Dim ServiceEndpoint As String
Directory.SetCurrentDirectory(Globals.WorkingDirectory)
Dim startPosition As Integer = InterfaceType.LastIndexOf(".") + 1
Dim InterfaceName As String = InterfaceType.Substring(startPosition)
InterfaceName = InterfaceName.Replace("Channel", "")
Dim doc As XDocument = XDocument.Load("../../app.config")
ServiceEndpoint = _
(From ep In doc.Descendants("endpoint")
Where (ep.Attribute("contract").Value.Contains(InterfaceName))
Select ep.Attribute("name")).Last().Value.ToString()
Return ServiceEndpoint
End Function
Now to find a workaround....
Re: ClickOnce and app.config file