防止在类库中创建 app.config
背景: 我创建了一个 Visual Studio 2010 解决方案,其中包含用于 Web 应用程序项目的单独项目和用于业务逻辑的类库。我希望在 Web 应用程序项目中定义连接和其他应用程序设置,并且没有类库的配置文件。即使我删除了 app.config 文件,类库中的某些内容也会继续重新创建该文件。我猜这与 LINQ to SQL dbml 文件有关。
问题 有谁知道如何防止在类库中自动生成 app.config ?
Background:
I've created a Visual Studio 2010 solution with a separate project for a Web Application project and Class Library for the business logic. I want the connections and other application settings defined within Web Application project and not have a config file for the Class Library. Something within the Class Library continues to recreate the app.config file even after I've deleted the file. My guess it is related to the LINQ to SQL dbml files.
Question
Does anyone know of a way to prevent the app.config from being auto generated in a Class Library?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法阻止生成 app.config。
我认为类库拥有自己的配置文件没有问题。我做 MVC Web 项目(与 winforms、webforms 或任何其他项目类型相同),其中有许多类库,每个类库都有自己的 app.config。
连接字符串仅存储在主 MVC 项目中。部署后,要么不部署这些配置文件,要么从其中删除连接字符串。只要它们(连接字符串)具有相同的名称,类库就会在主项目的配置中找到它并从那里使用它。
You can't prevent app.config being generated.
I see no problem with Class library having it's own config file. I do MVC Web projects (same as winforms, webforms or any other project type) with numerous Class libraries each having it's own app.config.
Connection strings are stored only in main MVC project. Upon deployment either don't deploy those config files or delete connection strings from them. As long as they (connection strings) have the same name, class library will find it in main project's config and use it from there.