我正在尝试在我的程序中添加ConfigurationMangager。我已经尝试过添加System.Configuration和System.Configuration.Install引用,但是没有任何效果。我还有别的办法可以解决这个问题吗?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
namespace Gmos.Halbtax.Models
{
static class Program
{
public static void connectDB()
{
string connString = ConfigurationManager.AppSettings["ConnString"].ToString();
SqlConnection conn = new SqlConnection(connString);
}
}
}发布于 2016-05-19 12:52:02
确保目标框架是NET framework 4,您为System.Configuration选择的版本是v4.0.0.0
单击项目上的“添加引用”,在项目中添加System.Configuration
若要检查项目属性,请转到->应用程序->目标框架
希望这能给你带来好处。
发布于 2016-05-19 13:03:05
如果没有显示引用:是否使用.Net框架4的客户端配置文件版本?如果是这样的话,下载整个框架,它应该是固定的。如果您已经使用了完整的版本,试着运行修复程序.在一些罕见的情况下,这种行为会发生。
https://stackoverflow.com/questions/37323560
复制相似问题