We have several applications within our company that we deploy via clickonce. However, these applications are deployed in multiple locations, and are hooked up to webservices/databases locally to the deployment (i.e. If we deploy to Aberdeen, we set up a DB in Aberdeen, and the appropriate application webservice is published there too).
Currently, when we deploy we have to remember to change the webservice reference to the appropriate URL, and change it for each deployment. Since this is a manual process, you can imagine that its prone to human error.
Is there any way to set up clickonce so that it has a knowledge of what the settings should be separately?
I had considered writing a VS addon that would allow you to set up multiple deployment URL's, and allow settings to be modified for each URL, however I've had severe difficulty in finding resources about writing VS addins (If anyone knows of a great resource to start this off, I would be highly appreciative).
The only other way I can think of is to do something like:
Friend ReadOnly Property wsTest() As wsTest.Service
Get
If _wsTest Is Nothing Then
_wsTest = New ws_ActiveDirectory.Service
End If
If System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed Then
Dim URL As String = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.ActivationUri.AbsoluteUri
Dim ServiceURL As String = My.Settings("ServiceURL_" & URL).ToString
_wsTest.URL = ServiceURL
End If
Return _wsTest
End Get
End Property
I could use a Hashtable property to do the same, but you get the idea. This looks clumsy though, so I was wondering if there is a better method of doing this?
Thanks Fergal
| | Fergal Reilly Monday, October 05, 2009 1:12 PM | I can't think of a way to do it in a completely automated process. You can put them in separate config files and then make sure you deploy the right config file, you could hardcode the whole list and then comment out just the one you're using, etc., etc. You could put a central file on the local server and look for it, but then you have to change the server you look for, right?
Have you tried the code you listed above? Is the deployment URL's server the same as the web service url's server?
We did something like this with post-build commands -- we copied one of two files depending on whether it was a debug or release configuration. I don't know if the deployment URL is available in the post-build commands, but it's an idea you could check out.
I'll mull this over; If I have any brilliant ideas, I'll let you know.
RobinDotNet Click here to visit my ClickOnce blog!Microsoft MVP, Client App Dev | | RobinDotNet Monday, October 05, 2009 3:56 PM | Thanks, I havent tried it yet, but no, the webservice URL is different (although probably on the same server), I'd intended to load the settings with each of the urls using the application url as a key. Its a difficult one, since clickonce is more designed for a single deployment, rather than multiple deployments. | | Fergal Reilly Tuesday, October 06, 2009 7:35 PM | If the base url of the webservice is the same, you could create the web service URLs in your application, right? So if the url of the deployment is http://123.456.789.000/MyCo/myapp.application and the web service is http://123.456.789.000/webservices/MyWebService.asmx then you could programmatically pull the URL from the application, and concatenate it with the /webservices/MyWebService.asmx. Do you even have that luxury? RobinDotNet Click here to visit my ClickOnce blog!Microsoft MVP, Client App Dev | | RobinDotNet Tuesday, October 06, 2009 8:39 PM | It's possible, but I can forsee scenarios where the webservice is stored on another server, so I'd like to counter that possibility. However its definately another solution to explore.
The same problem exists in the webservice itself to some extent, in that the web.config file has to point to the correct DB, but this changes depending on where its deployed. Currently we simply comment out the connection strings for the wrong DB's, which I suppose is an option here, but still falls foul of the human error component.
Thanks Fergal | | Fergal Reilly Wednesday, October 07, 2009 9:42 AM | I'd almost include an database (SQLCE?) or something with the info for all, and then have 1 setting that indicates the location and pull the info from the database. FYI about deploying SQLCE, you don't have to deploy it as a prerequisite, you can just include the dll's required for it to run and you're golden. RobinDotNet Click here to visit my ClickOnce blog!Microsoft MVP, Client App Dev | | RobinDotNet 22 hours 26 minutes ago | Ah thats an option I suppose. One thing I have done, which gets around the development/live divide is to have a application setting called URL_BASE_LIVE storing the local part of the URL. I then Have the following in a common module in the application:
Private WithEvents _wsTest As ws_Test.ws_Test
Friend ReadOnly Property wsTest() As ws_Test.ws_Test
Get
If _Test Is Nothing Then
_Test = New ws_Test.ws_Test
If System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed Then
_wsTest.Url = My.Settings.URL_Base_Live & "ws_Test.asmx"
End If
End If
Return _wsTest
End Get
End Property
This is particularly useful in my most recent app, where I have broken the various areas of functionality into their own webservices within the webservice application. It also means that, when running in Dev I hook up to the default URL (localhost:xxxx), but switch to the live when its published. This seems to work pretty well. I've never actually looked at the SCLCE stuff before, might be a handy solution. | | Fergal Reilly 17 hours 25 minutes ago |
|