Consequences of calling the .Net function exe main ()

In .net, exes are assemblies and can be specified as DLLs. This means that any of their types can be used from any other program if they are defined as public . What are the consequences of calling another exe Main function from your code? Obviously, the thread that is called by Main will be blocked until the program terminates, as opposed to spawning a new process. What other potential problems can this have?

+4
source share
2 answers

The program will run in AppDomain.

Therefore, any general state used by both programs can be confusing.

To solve this problem, you can call AppDomain.ExecuteAssembly .

In any case, the program itself may not process it correctly - the current directory, command line arguments and other state of each process (for example, environment variables) will be shared by the parent process.

+5
source

I looked at the AppDomains features in the Jeffery Richter CLR through C #. Here are the points he gives about what AppDomains provides to those who are interested in things that might be damaged / open security holes.

  • Objects created by code in one AppDomain cannot be accessed directly with code in another AppDomain

  • AppDomains can be unloaded

  • AppDomains can be individually protected.

  • AppDomains can be customized individually

0
source

Source: https://habr.com/ru/post/1316345/


All Articles