Redirect Console for In-Memory Execution
-
Hi, I am developing a scripting tool in which I want to compile and execute the code in MEMORY, not as an executable file. But in there I need to redirect the console output to a Richtextbox and input to a simple textbox. Example: The script code is like this
public class Script
{
public static void Main()
{
Console.WriteLine("Hello World");
Console.ReadKey();
}
}When I compile and execute in memory I want to print "Hello World" in a richtextbox and input the key from a textbox to terminate the application. How can I accomplish it? I know how to redirect input/output if it is an executable file, but I don't know how to do the same for in-memory execution. Can anyone please help me?
Anindya Chatterjee -------------------------------------------------------- 1. Don't Visit ..[^] 2. But Watch ..
-
Hi, I am developing a scripting tool in which I want to compile and execute the code in MEMORY, not as an executable file. But in there I need to redirect the console output to a Richtextbox and input to a simple textbox. Example: The script code is like this
public class Script
{
public static void Main()
{
Console.WriteLine("Hello World");
Console.ReadKey();
}
}When I compile and execute in memory I want to print "Hello World" in a richtextbox and input the key from a textbox to terminate the application. How can I accomplish it? I know how to redirect input/output if it is an executable file, but I don't know how to do the same for in-memory execution. Can anyone please help me?
Anindya Chatterjee -------------------------------------------------------- 1. Don't Visit ..[^] 2. But Watch ..
What is the benefit you are seeking by compiling and executing in memory? Does it outweigh the risks of potential security vulnerabilities this exposes? If this needed, why compile an entire application, just use the particular method that is necessary for your functionality.
only two letters away from being an asset
-
What is the benefit you are seeking by compiling and executing in memory? Does it outweigh the risks of potential security vulnerabilities this exposes? If this needed, why compile an entire application, just use the particular method that is necessary for your functionality.
only two letters away from being an asset
That is not the point. OK instead of in-memory execution I invoke the entry point function from the compiled assembly. But there also how would I redirect the console input output to a textbox or richtextbox?
Anindya Chatterjee -------------------------------------------------------- 1. Don't Visit ..[^] 2. But Watch ..
-
That is not the point. OK instead of in-memory execution I invoke the entry point function from the compiled assembly. But there also how would I redirect the console input output to a textbox or richtextbox?
Anindya Chatterjee -------------------------------------------------------- 1. Don't Visit ..[^] 2. But Watch ..
Anindya Chatterjee wrote:
how would I redirect the console input output to a textbox or richtextbox?
You don't. Execute the method from the assembly, get the output, then assign it to the textbox in your application.
only two letters away from being an asset
-
Anindya Chatterjee wrote:
how would I redirect the console input output to a textbox or richtextbox?
You don't. Execute the method from the assembly, get the output, then assign it to the textbox in your application.
only two letters away from being an asset
Sorry, I didn't get that. If the script has a line like:
Console.WriteLine("Hello World");
then how would I get the output and assign to the textbox? That entry-point function is not returning any string. If I am wrong please correct me with some example. And also what about Console.ReadKey() or Console.ReadLine(...) ? Thanks and regards,
Anindya Chatterjee -------------------------------------------------------- 1. Don't Visit ..[^] 2. But Watch ..
-
Sorry, I didn't get that. If the script has a line like:
Console.WriteLine("Hello World");
then how would I get the output and assign to the textbox? That entry-point function is not returning any string. If I am wrong please correct me with some example. And also what about Console.ReadKey() or Console.ReadLine(...) ? Thanks and regards,
Anindya Chatterjee -------------------------------------------------------- 1. Don't Visit ..[^] 2. But Watch ..
That's the point you can't do this. And why would you want to? If you have a textbox in your application and you need to pass the value from the textbox to an external application, then why do you need to try reassigning the input stream? Sounds more like you need to refactor the external application.
only two letters away from being an asset