简体   繁体   中英

Sharing global variables between two projects

My problem is that i have two projects in a solution (1x ASP , 1x Console ) and i want to share some data between them.

I tried it with a static class in the console-app. The problem is that the reference-class in the asp-app is a new one, and if I try to change something in this static class it is only changed in the asp-app but not in the console-app.

Thanks in advance!

The problem you have is that those two projects are going to run as two different processes. The ASP.NET project is going to get run by IIS, and your console project is simply a standard .NET app.

So, you'll need some sort of communication bridge between the two. If they're on the same machine, you could use files or named pipes, and if they're on different machines, you could take advantage of the fact that one of your processes is an ASP.NET web app and use web services. You could also use a database (but that might be overkill depending on your needs).

There are lots of approaches to do this, but the most common one is to use a database that is accessed by both processes.

If you could provide more context, it would make this easier to give you an accurate answer.

将其存储在注册表中并访问

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM