VB 2008 Configuartion Manager - Active solution configuation

J

jvcoach23

I'm using VB 2008. I installed the 2008 Web Deployment Setup. I've done
this with asp.net apps in 2005. Anyway.. here is the problem. I want to
create several solution configurations. This is a silverlight 2 application
that is using a web service to drive the data. in the webservice solution
there is a file called ConnectionString_debugTest.config file. inside that
file

<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="VerseSql" connectionString="Data
Source=(local);Uid=TestId;Pwd=TestPw;Initial Catalog=dbTest"/>
</connectionStrings>

in the added Web deployment project configuration, with the Test
configuation as the active one, under deployment, Web.config file section
replacements i've added the following
connectionStrings=ConnectionString_debugTest.config;

in the web service asmx.vb file that makes the db call is the following

Dim dbcon As String =
WebConfigurationManager.ConnectionStrings("VerseSql").ConnectionString()
cn = New SqlConnection(dbcon)

the problem is that when i run this and look and see what it's going after,
it says this
Referenced object has a value of 'nothing'

So i tried this instead
Dim connectionStrings As ConnectionStringSettingsCollection =
WebConfigurationManager.ConnectionStrings
Dim connectionStringsEnum As IEnumerator =
connectionStrings.GetEnumerator()
this give me a little more info.. it responses
? connectionstrings.Item(0)
{System.Configuration.ConnectionStringSettings}
ConnectionString: "data source=.\SQLEXPRESS;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User
Instance=true"
ElementInformation: {System.Configuration.ElementInformation}
LockAllAttributesExcept:
{System.Configuration.ConfigurationLockCollection}
LockAllElementsExcept:
{System.Configuration.ConfigurationLockCollection}
LockAttributes: {System.Configuration.ConfigurationLockCollection}
LockElements: {System.Configuration.ConfigurationLockCollection}
LockItem: False
Name: "LocalSqlServer"
ProviderName: "System.Data.SqlClient"
the connection string is not getting picked up.
So i look at the build order for this solution.
It's order is
1. silverlight
2. web site
3. web deployment

so if i'm reading this right, the web deployment shoudl be #1 so that it can
pick up the settings.

can someone help out and tell me where i've gone astray.
thanks
shannon
 
C

Cowboy \(Gregory A. Beamer\)

To have a really good deployment experience, you have to wait until VS 2010,
which has click once deployment. And, this is if they deliver what is
promised.

Options:

1. Set up a separate connection strings file linked to web.config (like
db.config) and drop that file from the deploy. This works nicely once it is
set up.

2. Create a postbuild step that swaps files (web.config or db.config)

3. Move to an automated deploy, using a tool like nAnt, and have the swap as
a step in that process

4. Wait until VS 2010, which has a much better user story for web deployment

--
Gregory A. Beamer
MVP; MCP: +I, Se, SD, DBA

*************************************************
| Think outside the box! |
*************************************************
 
Top