Re: Run source code on the fly from a browser

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thank you very much for the detailed information. I think I can find the way around from your response.




Jeffrey Tan[MSFT] wrote:
Hi Charles,

This is not an easy task, we have to employ the .Net compilation service with Reflection in server side to get this done.

.Net provides powerful access to the IL code generation process through the System.CodeDom.Compiler and Microsoft.CSharp and Microsoft.VisualBasic namespaces. For example, CSharpCodeProvider.CreateCompiler method will create an instance of the C# code compiler, which can be used to generate assembly in memory.

After compiling the code into an assembly, we have to decide how to execute it and get the result from it. We have 2 approaches:
1. Use Reflection to execute the code
2. Save the assembly to disk and use Process.Start to execute the assembly in another process. Then we can use Process.StandardOutput property to retrieve the output. However, this approach does not work if your are generating dll assembly.

The 2 articles below demonstrate the technical details of this complex task:
"Discover Dynamic Code Compilation"
http://www.codeguru.com/csharp/csharp/cs_misc/designtechniques/article.php/c
10729__2/
"Dynamically executing code in .Net"
http://www.west-wind.com/presentations/dynamicCode/DynamicCode.htm

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

.



Relevant Pages

  • Re: Intermittent work in UI thread
    ... Thank you again Joseph, that is exactly what I was trying to do. ... The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. ...
    (microsoft.public.vc.mfc)
  • Re: multithreaded tcp/ip server large page file
    ... Part of the processing being done by each thread is contacting a sql server and if the sql server is having problems processing by this program backs up and I've seen it with over 100 threads open before. ... It handles it fine as the sql request time out this program returns and error response to the TCP/IP client that the thread is handling and the sub/tread ends. ... The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: multithreaded tcp/ip server large page file
    ... Part of the processing being done by each thread is contacting a sql server and if the sql server is having problems processing by this program backs up and I've seen it with over 100 threads open before. ... It handles it fine as the sql request time out this program returns and error response to the TCP/IP client that the thread is handling and the sub/tread ends. ... The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: multithreaded tcp/ip server large page file
    ... Part of the processing being done by each thread is contacting a sql server and if the sql server is having problems processing by this program backs up and I've seen it with over 100 threads open before. ... It handles it fine as the sql request time out this program returns and error response to the TCP/IP client that the thread is handling and the sub/tread ends. ... The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: multithreaded tcp/ip server large page file
    ... Delete the original counters by clicking DELETE key on keyboard; ... The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. ...
    (microsoft.public.dotnet.languages.vb)