나는 런타임에 2013 년 웹 VS 2008 VS 2013System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration
코드는 2008 년에 완벽하게 실행으로 전환 프로젝트,하지만 오류가 있습니다.
StartUp 프로젝트 myWebPages에서 코드는 동일한 솔루션에서 myRemotingService라는 다른 프로젝트의 web.config를 읽습니다. 여기
코드의 일부입니다 :
Dim rootWebConfig1 As System.Configuration.Configuration
rootWebConfig1 = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/myRemotingService")
varConnectionString = rootWebConfig1.AppSettings.Settings.Item("ConnectionString").Value 'Error on this line
하지만 myWebPages에 myRemotingService에서의 Web.config를 복사 할 때. 과에 코드를 변경합니다
rootWebConfig1 = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/myWebPages")
varConnectionString = rootWebConfig1.AppSettings.Settings.Item("ConnectionString").Value
작품 좋은,하지만 난 더 myWebPages 유사한 프로젝트를 만들려고하기 때문에 Web.config의이 myRemotingService에 장소 싶어요.
코드에 어떤 문제가 있습니까?
감사
오류가 있습니다 : 개체 참조가 개체의 인스턴스로 설정되지 않았습니다
나는 또한 내가 인터넷
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
만의 길이에서 얻을 약간의 코드를 실행 appSettings.count는 0입니다.
"런타임시 2013에서 오류가 발생합니다." 오류가 무엇입니까? – Braiam
오류 : 객체 참조가 객체의 인스턴스로 설정되지 않음 – user3808458
[NullReferenceException은 무엇이며 어떻게 수정합니까?] (http://stackoverflow.com/questions/4660142/what-is-a) -nullreferenceexception-and-how-do-i-fix-it) –