类库中app.config中的连接字符串 [英] Connection string in app.config in a class library

查看:69
本文介绍了类库中app.config中的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建解决方案,并且内部有三个项目:

I am creating solution and inside I have three projects:


  1. WCF服务库项目

  1. A WCF Service Library Project

DataAccess项目(类库)

A DataAccess Project (Class Library)

用于承载WCF服务的网站

A Web site for hosting WCF service

该服务的实现是在项目1上进行的,但是为了访问数据库,我使用了另一个实现数据访问的项目

The implementation of the service is on the project # 1, but in order to access the DataBase I use a second project that implements the data access using a class library project.

这个问题是为了获得数据访问权限,我需要配置一个连接字符串,但是该连接字符串必须可以在生产环境中进行配置,我的意思是在生产中,我将部署该站点,这是一个非常简单的项目,仅包含参考WCF服务库项目,然后数据库部门的人员将配置连接字符串。

That problem is in order to get data access I need to configure a connection string, but that connection string must be configurable in a production environment, I meant in production I am going to deploy the site, which is a very simple project that contains only a reference WCF Service Library Project then a guy from database department will configure the connection string.

在开发中,我在数据访问项目上有一个app.config,但是当我发布该版本时,app.config嵌入在dll中。

In development I have an app.config on the data access project but when I do the release that app.config is embedded on the dll.

任何想法我们怎么能达到目的

Any ideas how can we achieve our purpose

推荐答案

app.config中的连接字符串(数据层)未嵌入dll中。

The connection string in your app.config (data layer) is not embedded in the dll.

如果您查看数据层项目中的app.config文件,则可能会有一个connectionStrings部分。您需要将connectionStrings放在WCF服务网站的web.config中。

If you look in the app.config file in your data layer project, you will probably have a connectionStrings section. you need to put the connectionStrings in the web.config of your WCF service website.

可以在您的生产环境中进行配置。

This can be configured in your production environment.

这篇关于类库中app.config中的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆