I have a web projects converted from VS 2008 to VS 2013.
The code runs perfectly in 2008, but errors on 2013 at runtime.
From the StartUp project named myWebPages, code will read a web.config in a different project named myRemotingService in the same solution.
Here are portion of the code:
Dim rootWebConfig1 As System.Configuration.Configuration
rootWebConfig1 = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/myRemotingService")
varConnectionString = rootWebConfig1.AppSettings.Settings.Item("ConnectionString").Value 'Error on this line
But when I copy the web.config from myRemotingService to myWebPages. and change the code to:
rootWebConfig1 = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/myWebPages")
varConnectionString = rootWebConfig1.AppSettings.Settings.Item("ConnectionString").Value
Works fine, but I want the web.config be place in myRemotingService because I'm going to build more myWebPages similar projects.
What is wrong with the code?
Thanks
There error is : Object reference not set to an instance of an object
I also run some code that I get from the internet
rootWebConfig1 =
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/myRemotingService")
Dim appSettings As KeyValueConfigurationCollection =
rootWebConfig1.AppSettings.Settings
Console.WriteLine("[appSettings for app at: {0}]", "/myRemotingService")
Dim key As String
For Each key In appSettings.AllKeys
Console.WriteLine("Name: {0} Value: {1}", _
key, appSettings(key).Value)
Next key
but the length of the appSettings.count is 0