Ich versuche den Zugang zu connectionStrings
aus der Konfigurationsdatei. Der Code ist ASP.NET + C#. Ich habe hinzugefügt System.Configuration
zu verweisen und auch bei der Verwendung erwähnt. Aber trotzdem wurde die Baugruppe nicht akzeptiert.
Ich verwende VSTS 2008. Haben Sie eine Idee, was der Grund dafür sein könnte?
Seltsam ist auch, dass der Name der Baugruppe als "System.configuration" angezeigt wird, also mit einem kleinen c, was bei anderen Systembaugruppen nicht der Fall ist.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
namespace Utility
{
public class CommonVariables
{
public static String ConnectionString
{
get { return ConfigurationManager.ConnectionStrings["EmployeeEntities"].ConnectionString; }
}
}
}
Konfig:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="qbankEntities" connectionString="metadata=res://*/qbankModel.csdl|res://*/qbankModel.ssdl|res://*/qbankModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=localhost;Initial Catalog=qbank;Persist Security Info=True;User ID=**;Password=****;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>