i am using a windows application as well as web application developed in visual studio 2010 beta 2 using .net framework 4 on windows xp/windows server 2008/windows7
i am able to read web.config file on system running windows XP sp2 but same is not read by windows 7 and windows server 2008
i installed my web application on iis 7 on said windows with .net 4 but it not read web.config by my windows application.
i used below code on form_load in windows application for reading that web.config-
Expand|Select|Wrap|Line Numbers
- Dim webStr As Configuration.Configuration=WebConfigurationManager.OpenWebConfiguration("/Site/")
- Dim webConstr As String = webStr.ConnectionStrings.ConnectionStrings("connStr").ConnectionString
- Dim getIdx As Integer = webConstr.IndexOf("User ID=", 0)
- getIdx += 8
- Dim getIdx2 As Integer = webConstr.IndexOf(";", getIdx)
- Dim strLen As Integer = getIdx2 - getIdx
- sqlUid = webConstr.Substring(getIdx, strLen)
Expand|Select|Wrap|Line Numbers
- <?xml version="1.0"?>
- <configuration>
- <connectionStrings>
- <remove name="LocalSqlServer"/>
- <add name="LocalSqlServer" connectionString="Data Source=myMacine;Initial Catalog=ASPNETDB;Persist Security Info=True;integrated security=true" providerName="System.Data.SqlClient"/>
- <add name="connStr" connectionString="Data Source=myMachine;Initial Catalog=abc;Persist Security Info=True;User ID=xyz;" providerName="System.Data.SqlClient"/>
- </connectionStrings>
- .......
- ......
- </configuration>
Expand|Select|Wrap|Line Numbers
- Failed to map the path '/site'
Expand|Select|Wrap|Line Numbers
- at System.Web.Configuration.ProcessHostConfigUtils.MapPathActual(String siteName, VirtualPath path)
- at System.Web.Configuration.ProcessHostMapPath.MapPathCaching(String siteID, VirtualPath path)
- at System.Web.Configuration.ProcessHostMapPath.System.Web.Configuration.IConfigMapPath2.MapPath(String siteID, VirtualPath path)
- at System.Web.Configuration.WebConfigurationHost.InitForConfiguration(String& locationSubPath, String& configPath, String& locationConfigPath, IInternalConfigRoot configRoot, Object[] hostInitConfigurationParams)
- at System.Configuration.Configuration..ctor(String locationSubPath, Type typeConfigHost, Object[] hostInitConfigurationParams)
- at System.Configuration.Internal.InternalConfigConfigurationFactory.System.Configuration.Internal.IInternalConfigConfigurationFactory.Create(Type typeConfigHost, Object[] hostInitConfigurationParams)
- at System.Web.Configuration.WebConfigurationHost.OpenConfiguration(WebLevel webLevel, ConfigurationFileMap fileMap, VirtualPath path, String site, String locationSubPath, String server, String userName, String password, IntPtr tokenHandle)
- at System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(String path)
- at appName.FormName.Form_Load(Object sender, EventArgs e) in E:\myapp\page.vb:line 130
i have to install it by two day so please help me
thanks in advanced