根据解决方案配置进行设置

编程入门 行业动态 更新时间:2024-10-11 07:28:53
本文介绍了根据解决方案配置进行设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好, 请让我解释一下我的情况和需求: -2个独立文件夹中的2个数据库(测试/生产数据) -1个数据集(设置的路径) 环境: VS2008,C#3.5 现在,我要选择/配置数据库的路径,具体取决于 活动解决方案配置上的信息(调试/发布/...) 反正有可能吗? 有人知道该怎么做到吗? 提前谢谢! ToniM

Hello there, Please let me explain my situation and my needs: - 2 databases in 2 seperate folders (Testing / productive data) - 1 dataset (path from settings) Environment: VS2008, C#3.5 Now i want to choose / configure the path to the database depending on the active solution configuration (Debug / Release / ...) Anyway is it possible at all? Does anybody know how to achive this? Thanks in advance! ToniM

推荐答案

我无法发表评论,所以我发表了答案! ;) 起初,我不熟悉 settings.settings app.config dataset.xsd 的交互.你能跟我解释一下吗? 为什么两个文件中都有相同的配置字符串?如果仅在App.config中进行更改,则在打开设置文件时会出现问题. 我不能落后...:confused: 设置文件位于属性"->中.它将被编译成二进制->我无法在输出文件夹中更改. (如果只更改了app.config,我希望会出现上述错误) I cannot post a comment, so i post a answer! ;) At first im not familiar with the interaction of settings.settings and app.config and the dataset.xsd. Can you explain it to me? Why is there in both files the same configuration string? and if you change it only in the App.config there is a problem when you open the settings file. I can not get behind it ... :confused: The settings file is in the Properties -> it will be compiled into the binary -> i cannot change in output folder. (If you change just the app.config i expect an error, mentioned above)

我发现至少一个解决方法-如果有人有更好的方法,请让我知道! 这是我的解决方案: 我将所有内容(DataSet,TableAdapters,TableAdapterManager)放入单个包装器类中,并通过属性提供了这些DataSet,TableAdapters和TableAdapterManager. 在构造函数中,我根据需要更新每个TableAdapter的ConnectionString(TableAdapter.Connection.ConnectionString). 我需要一个高效的测试数据库,因此我将测试路径设置为默认路径(在DataSet设计器中),并在其高效部署时进行更改. 我肯定这不是最好的解决方案,但是它可以工作,直到我发现或有人告诉我更好的方法为止. ToniM I found at least a workaround - if somebody has a better way, please let me know! here is my solution: I put everything (DataSets, TableAdapters, TableAdapterManager) into a singleton wrapper class and provide those DataSets, TableAdapters and TableAdapterManager through properties. In the constructor i update the ConnectionString of each TableAdapter (TableAdapter.Connection.ConnectionString) depending on my needs. I need a productive and a test database, so i set the test path as default (in the DataSet designer) and just change it when its a productive deploy. Im sure its not the best solution, but it works until i find out or somebody tell me a better way. ToniM

更多推荐

根据解决方案配置进行设置

本文发布于:2023-11-13 11:07:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584198.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:解决方案

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!