views:

109

answers:

1

Hi,

I have a VS2008 Solution that contains a Client project, WindowsService project, and ServiceConsole project. When I deploy, I would like the WindowsService and ServiceConsole to be in the same folder since ServiceConsole needs access to WindowsService's app.config (i.e. Settings.settings) file to configure it. Is this possible with ClickOnce? If so, what are the steps to achieve this?

My other question is regarding the Client's Setup. Once the setup files are published to a location on a file server, is it possible to modify it's application settings? If so, where are they located? I would like to set the server's IP Address from my ServiceConsole application so that the user installing the Client doesn't have to worry about it.

Thanks for any help.

+1  A: 

Add the app.config to the ServiceConsole's project as a link (Add Existing Item, Navigate to it, and then choose "Add as Link" from the "Add" Split button). You'll then need to set that it's "Content" and "Always Copy" in the build properties for the link. Lastly, go into the "Files" dialog for the Publish tab, and make sure it's listed there. You may need to "Show all files" to see it.

For your second question: I have a tendency not to write to an app's settings file because the newly written settings are per-user. They get buried in one of those hidden folders inside the user's profile directory. I'd recommend using a fixed location (like CSIDL_COMMON_DOCUMENTS) using this code:

Private Declare Function SHGetSpecialFolderPath Lib "shell32.dll" Alias "SHGetSpecialFolderPathA" _
    (ByVal hwndOwner As IntPtr, <Out()> ByVal lpszPath As StringBuilder, ByVal nFolder As Integer, ByVal fCreate As Boolean) As Boolean
Private Const CSIDL_COMMON_DOCUMENTS As Integer = &H2E

<snip>

Dim lpszPath As New StringBuilder(260)
If SHGetSpecialFolderPath(IntPtr.Zero, lpszPath, CSIDL_COMMON_DOCUMENTS, True) Then
    _sharedDocsDir = lpszPath.ToString()
Else
    Throw New InvalidDataException("Couldn't get working directory root.")
End If

To answer your final question, I think the reason it works fine for me is that we use System.Configuration, instead of the designer-generated code. What you can probably do is pull your settings classes out to third assembly (fourth?) and just reference that assembly by both projects. It would probably work better than linking the app.config.

Bob King
Bob, do I also need to link in the Settings.settings file? When I do as you suggested and then compile, lots of errors occur like :Could not find schema information for the element 'userSettings'. Could not find schema information for the element 'Server.Properties.Settings'. The ServiceConsole doesn't have any Settings.setting file.
Lenard
Bob, I re-worded the second question.
Lenard