Re: Run source code on the fly from a browser
- From: Charles Zhang <CharlesZhang@xxxxxxxxxxxxxxxxx>
- Date: Mon, 18 Sep 2006 20:26:32 -0700
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.
- References:
- Run source code on the fly from a browser
- From: Charles Zhang
- RE: Run source code on the fly from a browser
- From: "Jeffrey Tan[MSFT]"
- Run source code on the fly from a browser
- Prev by Date: RE: OutOfMemoryException in Visual Studio 2005
- Next by Date: MSBuild's ResolveVCProjectOutput broken
- Previous by thread: RE: Run source code on the fly from a browser
- Next by thread: Enumerating Information about other windows.
- Index(es):
Relevant Pages
|