c++/cli 读取配置文件app.config所需的设置
2015-01-27 13:16
357 查看
app.config文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="MusicConnectionString" connectionString="Data Source=(local);Initial Catalog=MusicEditDB;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>自定义类SQLHelper:
问题:CONN_STRING为null,数据库不能正常的读写
原因:c++/cli中app.config不会自动生成到debug目录
解决:项目属性->生成事件(Build Events),三个事件点,随便添到那个步骤中:
命令行:copy app.config "$(TargetPath).config"
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="MusicConnectionString" connectionString="Data Source=(local);Initial Catalog=MusicEditDB;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>自定义类SQLHelper:
public static readonly string CONN_STRING = ConfigurationManager.ConnectionStrings["MusicConnectionString"].ConnectionString.ToString();
问题:CONN_STRING为null,数据库不能正常的读写
原因:c++/cli中app.config不会自动生成到debug目录
解决:项目属性->生成事件(Build Events),三个事件点,随便添到那个步骤中:
命令行:copy app.config "$(TargetPath).config"
相关文章推荐
- 类库如何读取配置文件(app.config)?
- 如何配置及读取App.config文件
- winform中读取配置文件App.config的一些事
- C# 读取app.config配置文件 节点键值,提示 "配置系统未能初始化" 错误的解决方案
- C# 读取app.config配置文件 节点键值,提示 "配置系统未能初始化" 错误的解决方案
- C#读取app.config配置文件中的connectionString节点
- C# 读取不在同一个程序集中的配置文件app.config
- c# c/s 框架读取的配置文件时是app.exe.config
- C#_App.config配置文件的读取与更新
- C# 读取保存App.config配置文件的完整源码参考
- 读取和修改App.config配置文件
- winform程序读取和改写配置文件App.config元素的值
- C#中读取App.config配置文件代码实例
- 记录下vs2008 读取 App.config 配置文件
- winform程序读取和改写配置文件App.config元素的值
- C# 读取保存App.config配置文件的完整源码参考(转)
- winform程序读取和改写配置文件App.config元素的值
- winform程序读取和改写配置文件App.config元素的值
- c#读取配置文件 程序的App.config
- Window form中App.config配置文件的添加和读取