Many times when Im working in a project I will always forget simple things in the framework. I usually end up adding a console app, testing it out, and then adding it to what Im working on. I was thinking today that it would be nice to have a simple utility
app where I could type in simple code, click a button, and have it compile and display the result.
So for example if one was to forget if the Path.GetDirectoryName(str) returned a "\" at the end the person could type this code in the utility app and see a result much easier then having to create a console app.
I guess of course the response is why the hell would you need it since that is what you can do with a console app? Beats me really I would just like something lightweight.
Is there something like this out there outside of vs? Is writing something like this feasible and if so what would I need to look into to compile things on the fly so to speak?
-
-
Maybe the command window can help you, although it can only be used while debugging.
Otherwise such an app would be fairly trivial to write, as you can invoke the C# compiler from code. Look up the Microsoft.CSharp.Compiler class in the docs. Or you could use the CodeDom compilation facilities, look at the CSharpCodeProvider and the VBCodeProvider class for instance (which I think can also be used to compile to an assembly in memory instead of to a file, after which you can use reflection to call some predefined function in the in-memory assembly). -
cool, thanks Sven. That will get me started.
-
Although not exactly what you're looking for, I use a little program called SnippetCompiler to test out little bits and pieces of code without having to create yet another VS project.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.