简体   繁体   English

如何在父控制台应用程序和ASP.NET Web应用程序之间共享app.config

[英]How to share app.config between parent console application and ASP.NET web application

Scenario 情境

  • I have a web application project and a console project. 我有一个Web应用程序项目和一个控制台项目。
  • The console project is used to send reports in batch and has settings in app.config pertaining to email. 控制台项目用于批量发送报告,并在app.config中具有与电子邮件有关的设置。
  • Sometimes methods in the console project are call from the web application. 有时,控制台项目中的方法是从Web应用程序调用的。

After deploying the website, I make sure that I copy consoleProject.exe.config and place it in the same bin folder as consoleProject.exe . 部署网站后,请确保我复制consoleProject.exe.config并将其放置在与consoleProject.exe相同的bin文件夹中。

Problem 问题

After deployment, If I make changes to consoleProject.exe.config , the changes are not recognized when calling methods in consoleProject.exe from the web application. 部署后,如果我对consoleProject.exe.config进行了更改, 则从 Web应用程序调用consoleProject.exe中的方法时,这些更改将无法识别。

Is this default app.config file only referred to when the actual app is being executed? 是否仅在执行实际应用程序时引用此默认app.config文件?

Yes, if you're calling code in the console app from the web app, it is treated the same as if you were calling a dll, and your web.config is used. 是的,如果您要从Web应用程序在控制台应用程序中调用代码,则将其与调用dll一样对待,并使用了web.config。

Similarly, if you call from the console application into code within a web app dll, the app.exe.config file will be used. 同样,如果您从控制台应用程序调用Web应用程序dll中的代码,则将使用app.exe.config文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.NET MVC应用程序从app.config(而不是web.config)获取绑定重定向设置 - ASP.NET MVC application getting binding redirect settings from app.config, not web.config 如何在ASP.NET MVC 5应用程序和.NET控制台应用程序之间共享数据库? - How to share a database between ASP.NET MVC 5 application and .NET console application? asp.net 内核中的控制台应用程序和 Web 应用程序之间的区别 - Difference between a console application and Web application in asp.net core .net 控制台应用程序中 app.config 文件中的 html 标签 - html tags in app.config file in .net console application 在 app.config 中为控制台应用程序存储值 - storing value in app.config for console application 可以在app.config中模拟控制台应用程序吗? - Possible to impersonate in app.config for console application? 如何在控制台应用程序中将值永久写入app.config文件? - How to write value to app.config file permanently in a console application? 如何在Win控制台应用程序中读取加密的app.config appSettings? - how to read encrypted app.config appSettings in win console application? 如何在控制台应用程序中添加App.Config文件 - How to add App.Config file in Console Application 如何在同一台机器和同一应用程序池中的 ASP.NET Web 应用程序之间共享会话? - How to share sessions between ASP.NET Web Apps in same machine and same application pool?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM